我一直在寻找有关我遇到的这个特殊问题的一些信息,我希望能够模拟鼠标左键单击我当前附加到的程序。
现在,我创建了一个线程来检查数据库中的某些值,当这些值返回时(我正在寻找的值),我希望能够在任何 x,y 坐标中发送鼠标左键单击程序(最小化时)。
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;
}