| | |
| | | #include "Win32Util.h" |
| | | |
| | | #include <thread> |
| | | #include <vector> |
| | | |
| | | |
| | | void clickRunner(int delay) // 函数名字可随意 |
| | |
| | | Sleep(delay); |
| | | for (int i = 0;i < nums.length();i++) |
| | | { |
| | | keybd_event(nums.c_str()[i], 0, 0, 0); |
| | | int code = int(nums.c_str()[i]); |
| | | if (code == '.') |
| | | { |
| | | code = 110; |
| | | } |
| | | keybd_event(code, 0, 0, 0); |
| | | Sleep(5); |
| | | keybd_event(nums.c_str()[i], 0, KEYEVENTF_KEYUP, 0); |
| | | keybd_event(code, 0, KEYEVENTF_KEYUP, 0); |
| | | Sleep(20); |
| | | |
| | | } |
| | | |
| | | } |
| | |
| | | void Win32Util::keyboard(int code, int delay) { |
| | | thread runner(kbKeyRunner, code, delay); |
| | | runner.join(); |
| | | } |
| | | } |
| | | |
| | | DEVMODE Win32Util::getL2ScreenInfo() |
| | | { |
| | | //获取屏幕数量 |
| | | DEVMODE dm; |
| | | int screenNUm = GetSystemMetrics(SM_CMONITORS); |
| | | for (int i = 0;i < screenNUm;i++) { |
| | | DISPLAY_DEVICE device; |
| | | ZeroMemory(&device, sizeof(DISPLAY_DEVICE)); |
| | | device.cb = sizeof(DISPLAY_DEVICE); |
| | | EnumDisplayDevices(NULL, i, &device, NULL); |
| | | |
| | | |
| | | ZeroMemory(&dm, sizeof(dm)); |
| | | dm.dmSize = sizeof(dm); |
| | | EnumDisplaySettings(device.DeviceName, ENUM_CURRENT_SETTINGS, &dm); |
| | | |
| | | if (dm.dmPelsWidth > 3000) { |
| | | return dm; |
| | | } |
| | | } |
| | | throw string("尚未找到适合L2的显示设备"); |
| | | return DEVMODE(); |
| | | } |
| | | |
| | | void Win32Util::moveWin(HWND win, int x, int y, int width, int height) { |
| | | MoveWindow(win,x,y,width,height,TRUE); |
| | | } |
| | | |
| | | bool Win32Util::isWindowShow(HWND win) { |
| | | return IsWindowVisible(win); |
| | | } |
| | | |
| | | void Win32Util::showWindow(HWND hwnd) { |
| | | ShowWindow(hwnd, SW_SHOWNORMAL); |
| | | } |
| | | |
| | | |
| | | |