From 67a5e3d825fde17b7b00906ce42b0bd8cafebc4e Mon Sep 17 00:00:00 2001 From: admin <weikou2014> Date: 星期四, 18 八月 2022 18:22:14 +0800 Subject: [PATCH] '完善' --- ConsoleApplication/THSActionUtil.cpp | 105 +++++++++++++++++++++++++++++++++++++++++++++++++--- 1 files changed, 98 insertions(+), 7 deletions(-) diff --git a/ConsoleApplication/THSActionUtil.cpp b/ConsoleApplication/THSActionUtil.cpp index 6d88b06..8fc9d8a 100644 --- a/ConsoleApplication/THSActionUtil.cpp +++ b/ConsoleApplication/THSActionUtil.cpp @@ -2,13 +2,24 @@ #include "ImgDivider.h" #include "Win32Util.h" -bool isMainScreen(string str) { +bool isL2Screen(string str) { if (str.find("同花顺(") != string::npos) { cout << str << endl; if (str.find("副屏") == string::npos) { if (str.find("热门股") != string::npos || str.find("我的板块") != string::npos) { return true; } + } + } + return false; +} + + +bool isMainScreen(string str) { + if (str.find("同花顺(") != string::npos) { + cout << str << endl; + if (str.find("副屏") == string::npos) { + return true; } } return false; @@ -98,7 +109,7 @@ //获取副屏1 -HWND getSecondWindow() { +HWND THSActionUtil::getSecondWindow() { list<HWND> wlist = Win32Util::searchWindow("同花顺("); list<HWND>::iterator ele; for (ele = wlist.begin();ele != wlist.end();ele++) { @@ -112,7 +123,7 @@ return 0; } -HWND THSActionUtil::getL2Win() { +HWND THSActionUtil::getMainWin() { list<HWND> wlist = Win32Util::searchWindow("同花顺("); list<HWND>::iterator ele; for (ele = wlist.begin();ele != wlist.end();ele++) { @@ -121,6 +132,22 @@ if (isMainScreen(str)) { + return hwnd; + } + + } + return 0; +} + +HWND THSActionUtil::getL2Win() { + list<HWND> wlist = Win32Util::searchWindow("同花顺("); + list<HWND>::iterator ele; + for (ele = wlist.begin();ele != wlist.end();ele++) { + HWND hwnd = *ele; + string str = Win32Util::getWindowName(hwnd); + + + if (isL2Screen(str)) { return hwnd; } @@ -147,7 +174,7 @@ fp2 = true; } - if (isMainScreen(str)) { + if (isL2Screen(str)) { zp = true; } @@ -189,7 +216,7 @@ break; } - if (isMainScreen(str)) { + if (isL2Screen(str)) { cout << hwnd << endl; //获取尺寸 RECT rc; @@ -226,6 +253,69 @@ Win32Util::click(x + 10, y + 21 * 7 + 5, 500); } } + + + +void THSActionUtil::openThirdScreen() { + + list<HWND> wlist = Win32Util::searchWindow("同花顺("); + + bool open = false; + HWND mainPage = 0; + + list<HWND>::iterator ele; + for (ele = wlist.begin();ele != wlist.end();ele++) { + HWND hwnd = *ele; + string str = Win32Util::getWindowName(hwnd); + if (isThirdScreen(str)) + { + cout << str << endl; + SetForegroundWindow(hwnd); + SetFocus(hwnd); + open = true; + break; + } + + if (isL2Screen(str)) { + cout << hwnd << endl; + //获取尺寸 + RECT rc; + GetWindowRect(hwnd, &rc); + if (rc.right - rc.left > 200 && rc.bottom - rc.top > 200) { + mainPage = hwnd; + } + } + + } + + if (!open) { + if (mainPage <= 0) { + throw string("未找到首页"); + } + + Win32Util::focus(mainPage); + //查找主窗口的工具栏 + HWND tool = FindWindowExA(mainPage, NULL, "AfxControlBar100s", NULL); + + //获取第一个子窗口 + tool = FindWindowExA(tool, NULL, NULL, NULL); + cout << "操作栏:" << tool << endl; + //打开副屏,多窗按钮ID为:0x00007AF9 + HWND btn = GetDlgItem(tool, 0x00007AF9); + RECT rc; + GetWindowRect(btn, &rc); + //获取需要点击的位置 + int x = rc.left + (rc.right - rc.left) / 3; + int y = rc.top + (rc.bottom - rc.top) / 3; + //点击多窗 + Win32Util::click(x, y); + Sleep(50); + //点击副屏2 + Win32Util::click(x + 10, y + 21 * 8 + 5, 500); + } +} + + //添加股票 bool THSActionUtil::setGP(std::string quickCode, list<std::string> codeList, RecognitionManager* recognitionManager) { @@ -1149,7 +1239,7 @@ for (ele = wlist.begin();ele != wlist.end();ele++) { HWND hwnd = *ele; string str = Win32Util::getWindowName(hwnd); - if (isMainScreen(str)) { + if (isL2Screen(str)) { cout << hwnd << endl; //获取尺寸 RECT rc; @@ -1236,7 +1326,8 @@ int x = rc.left + result.startx + 5; int y = rc.top + result.starty + 5; Win32Util::focus(content); - Win32Util::click(x, y, 50); + //间隔1200ms再点击 + Win32Util::click(x, y, 1200); return true; } } -- Gitblit v1.8.0