| | |
| | | SetFocus(hwnd); |
| | | } |
| | | |
| | | void Win32Util::copy(string text) |
| | | { |
| | | HWND hWnd = NULL; |
| | | OpenClipboard(hWnd);//打开剪切板 |
| | | EmptyClipboard();//清空剪切板 |
| | | HANDLE hHandle = GlobalAlloc(GMEM_FIXED, 1000);//分配内存 |
| | | char* pData = (char*)GlobalLock(hHandle);//锁定内存,返回申请内存的首地址 |
| | | strcpy(pData, text.c_str()); |
| | | SetClipboardData(CF_TEXT, hHandle);//设置剪切板数据 |
| | | GlobalUnlock(hHandle);//解除锁定 |
| | | CloseClipboard();//关闭剪切板 |
| | | } |
| | | |
| | | //键盘输入数字 |
| | | void Win32Util::keyboardNum(string num, int delay) { |
| | | thread runner(kbNumRunner, num, delay); |
| | |
| | | void Win32Util::keyboard(int code, int delay) { |
| | | thread runner(kbKeyRunner, code, delay); |
| | | runner.join(); |
| | | } |
| | | |
| | | void Win32Util::keyboardPaste() |
| | | { |
| | | keybd_event(VK_CONTROL, 0, 0, 0); // 按下CTRL键 |
| | | keybd_event('V', 0, 0, 0); // 按下a键 |
| | | Sleep(50); |
| | | keybd_event('V', 0, KEYEVENTF_KEYUP, 0);// 松开a键 |
| | | keybd_event(VK_CONTROL, 0, KEYEVENTF_KEYUP, 0);// 松开CTRL键 |
| | | } |
| | | |
| | | DEVMODE Win32Util::getL2ScreenInfo() |
| | |
| | | ShowWindow(hwnd, SW_SHOWNORMAL); |
| | | } |
| | | |
| | | void Win32Util::selectTexFileWin10(HWND hwnd, string path) |
| | | { |
| | | //选择路径 |
| | | HWND pathWin = FindWindowExA(hwnd, NULL, "WorkerW", NULL); |
| | | pathWin = FindWindowExA(pathWin, NULL, "ReBarWindow32", NULL); |
| | | pathWin = FindWindowExA(pathWin, NULL, "Address Band Root", NULL); |
| | | pathWin = FindWindowExA(pathWin, NULL, "msctls_progress32", NULL); |
| | | pathWin = FindWindowExA(pathWin, NULL, "Breadcrumb Parent", NULL); |
| | | pathWin = FindWindowExA(pathWin, NULL, "ToolbarWindow32", NULL); |
| | | RECT p; |
| | | GetWindowRect(pathWin, &p); |
| | | Win32Util::focus(hwnd); |
| | | Win32Util::click(p.right - 5, p.top + 5, 10); |
| | | Sleep(1000); |
| | | |
| | | //复制路径 |
| | | Win32Util::copy(path); |
| | | //粘贴路径 |
| | | keyboardPaste(); |
| | | |
| | | //按enter按键 |
| | | keybd_event(VK_RETURN, 0, 0, 0); |
| | | keybd_event(VK_RETURN, 0, KEYEVENTF_KEYUP, 0); |
| | | |
| | | |
| | | |
| | | |
| | | //选着导入Txt |
| | | HWND typeWin = FindWindowExA(hwnd, NULL, "ComboBox", NULL); |
| | | GetWindowRect(typeWin, &p); |
| | | Win32Util::focus(typeWin); |
| | | Win32Util::click(p.right - 5, p.top + 5, 10); |
| | | Win32Util::click(p.right - 5, p.bottom + 30, 100); |
| | | Sleep(500); |
| | | |
| | | |
| | | |
| | | //选中文件 |
| | | HWND contentWin = FindWindowExA(hwnd, NULL, "DUIViewWndClassName", NULL); |
| | | contentWin = FindWindowExA(contentWin, NULL, "DirectUIHWND", NULL); |
| | | HWND contentWin_ = FindWindowExA(contentWin, NULL, "CtrlNotifySink", NULL); |
| | | |
| | | for (int i = 0;i < 5;i++) |
| | | { |
| | | if (FindWindowExA(contentWin_, NULL, "SHELLDLL_DefView", NULL) > 0) |
| | | break; |
| | | contentWin_ = FindWindowExA(contentWin, contentWin_, "CtrlNotifySink", NULL); |
| | | } |
| | | GetWindowRect(contentWin_, &p); |
| | | |
| | | |
| | | Win32Util::click(p.left + 20, p.top + 10, 10); |
| | | Win32Util::click(p.left + 20, p.top + 10, 10); |
| | | Win32Util::click(p.left + 20, p.top + 10, 10); |
| | | |
| | | //Sleep(100); |
| | | |
| | | //点击打开 |
| | | //HWND openWin = FindWindowExA(hwnd, NULL, NULL, "打开(&O)"); |
| | | //GetWindowRect(openWin, &p); |
| | | //return; |
| | | //Win32Util::click((p.left + p.right) / 2, (p.top + p.bottom) / 2, 100); |
| | | } |
| | | |
| | | void Win32Util::rollMouseWheel(bool back, HWND win,int x, int y) |
| | | { |
| | | //back-是否往后滚 |
| | | SendMessage(win, WM_MOUSEWHEEL, back?0xFF880000:0x00780000, MAKEWORD(x, y)); |
| | | } |
| | | |
| | | void Win32Util::getWindowRect(HWND hwnd, RECT *rect) |
| | | { |
| | | GetWindowRect(hwnd, rect); |
| | | } |
| | | |
| | | |
| | | |