#include "common/pch.h" #include "ThsUtil.h" #include "../common/Win32Util.h" #include "ConfigUtil.h" HWND ThsUtil::get_trade_refesh_hwnd() { list hwnds = Win32Util::searchWindow("ÍøÉÏ¹ÉÆ±½»Ò×ϵͳ"); if (hwnds.size() <= 0) { return 0; } for (list::iterator el = hwnds.begin(); el != hwnds.end(); el++) { HWND hwnd = *el; HWND content_hwnd = FindWindowEx(hwnd, NULL, L"AfxMDIFrame140s", NULL); HWND temp = FindWindowEx(content_hwnd, NULL, L"#32770", NULL); for (int i = 0; i < 10; i++) { if (Win32Util::isWindowShow(temp)) { break; } temp = FindWindowEx(content_hwnd, temp, L"#32770", NULL); } if (!temp) continue; HWND t1 = FindWindowEx(temp, NULL, NULL, L"¹ýÂË"); if (!Win32Util::isWindowShow(t1)) continue; HWND tool_hwnd = FindWindowEx(hwnd, NULL, L"ToolbarWindow32", NULL); temp = FindWindowEx(tool_hwnd, NULL, L"#32770", NULL); if (temp) { HWND nq = FindWindowEx(temp, NULL, NULL, L"ÄÚǶ"); if (nq && Win32Util::isWindowShow(nq)) continue; return tool_hwnd; } } return 0; } HWND ThsUtil::get_ths_second_screen_menu_hwnd() { list hwnds = Win32Util::searchWindow("¸±ÆÁ1"); if (hwnds.size() > 0) { HWND hwnd =* hwnds.begin(); hwnd = FindWindowEx(hwnd, NULL, L"AfxFrameOrView100s", NULL); HWND temp=0 ; for (int i = 0; i < 100; i++) { temp = FindWindowEx(hwnd, temp, L"AfxWnd100s", NULL); if (Win32Util::isWindowShow(temp)) { RECT rect; Win32Util::getWindowRect(temp, &rect); if (rect.bottom - rect.top > rect.right - rect.left) break; } } if (temp <= 0) return 0; hwnd = temp; hwnd = FindWindowEx(hwnd, NULL, L"#32770", NULL); hwnd = FindWindowEx(hwnd, NULL, L"block_list_page", NULL); if (hwnd > 0) return hwnd; } return 0; } void ThsUtil::run_trade_refresh() { HWND hwnd = get_trade_refesh_hwnd(); int count = 0; while (TRUE) { count += 1; if (count > 10) { count = 0; hwnd = get_trade_refesh_hwnd(); } try { if (hwnd <= 0) { Sleep(20); continue; } // ²âÊÔ if (!ConfigUtil::isTradeRefresh()) { Sleep(20); continue; } RECT rect; Win32Util::getWindowRect(hwnd, &rect); Win32Util::visualClick(hwnd, MAKELONG(210, (rect.bottom - rect.top) / 2)); //Win32Util::visualClick(hwnd, MAKELONG(180,(rect.bottom - rect.top) / 2)); int time_space = ConfigUtil::getThsAutoRefreshTimeSpace(); if (time_space <= 0) { time_space = 500; } Sleep(time_space); } catch (...) { } Sleep(20); } } HWND ThsUtil::get_ths_flash_sell_win() { auto hwnd = GetDesktopWindow(); HWND mainPage = HWND(); //»ñÈ¡×ÀÃæ×Ó´°¿Ú¾ä±ú hwnd = GetWindow(hwnd, GW_CHILD); list list; while (hwnd != NULL) { const int bufferSize = 256; TCHAR className[bufferSize]; GetClassName(hwnd, className, bufferSize); if (CString(className).Find( L"#32770")==0) { if (FindWindowEx(hwnd, NULL, NULL, L"Ò»¼üÂô³ö[S]") >0) { return hwnd; } } hwnd = GetNextWindow(hwnd, GW_HWNDNEXT); } return HWND(); } std::wstring ThsUtil::get_ths_flash_sell_name() { HWND hwnd = get_ths_flash_sell_win(); if (hwnd <= 0) { return L""; } HWND nameHWND = GetDlgItem(hwnd, 0x0000040C); std::wstring name = Win32Util::getText(nameHWND); return name; }