我一直在尋找一些關於這個特定問題的方法,我希望能夠模擬在我目前附加的程序上點擊鼠標左鍵。C++模擬鼠標左鍵點擊最小化程序
現在,我創建一個線程來檢查數據庫中的某些值,當這些值返回時(我正在查找的值),我希望能夠在任何x中發送鼠標左鍵單擊,該程序的協調(儘管最小化)。
Windows 7如何做到這一點?謝謝!
編輯:這是我如何打電話線程...
HWND child = GetActiveWindow();
if (child == NULL)
MessageBox(0,"Couldn't get the child hwnd!","",0);
DWORD ID;
HANDLE thread_check_game = CreateThread (NULL , 0 , (LPTHREAD_START_ROUTINE) game_check_thread , (LPVOID)child, 0 , &ID); CloseHandle (game_check_thread);
然後......
DWORD WINAPI game_check_thread(LPVOID lpParam) {
HWND Window;
Window = (HWND)lpParam;
// ... some other code ...
// ...
WORD mouseX = 398;
WORD mouseY = 398;
SendMessage(Window,WM_LBUTTONDOWN,MK_LBUTTON,MAKELPARAM(mouseX,mouseY));
SendMessage(Window, WM_LBUTTONUP, MK_LBUTTON, MAKELPARAM(mouseX, mouseY));
Write("Sent Left Click\n");
ExitThread(0);
return 0;
}
爲什麼幾乎每週都會問這個問題的變種?人們不再搜索了嗎? – Deanna 2012-08-15 12:08:04
[同一問題在.Net](http://stackoverflow.com/questions/7029453/simulate-mouse-click-on-a-minimized-window?rq=1)。 – Deanna 2012-08-15 12:08:54