一个鼠标按下问题
本帖最后由 拈花小仙 于 2014-8-13 08:31 编辑#include <iostream>
#include <Windows.h>
int main()
{
RECT r;
POINT p;
POINT p1;
HWND gameh = FindWindow(NULL,TEXT("植物大战僵尸"));
GetWindowRect(gameh,&r);
GetCursorPos(&p);
p1.x = r.left + 556;
p1.y = r.top + 827;
SetCursorPos(p1.x,p1.y);
Sleep(100);
mouse_event(MOUSEEVENTF_LEFTDOWN,p1.x,p1.y,0,0);
mouse_event(MOUSEEVENTF_LEFTUP,0,0,0,0);
SetCursorPos(p1.x,p1.y);
return 0;
}
鼠标移动到某个坐标,并按下鼠标左键,这个程序只能移动位置,却不能按下鼠标左键,这是为什么呢?
试试这样行不
#include <Windows.h>
int main()
{
HWND gameh = FindWindow(L"MainWindow",NULL);
SetForegroundWindow(gameh);
POINT p2;
p2.x=385;
p2.y=450;
LPARAM lMousePos;
lMousePos=((p2.y*0x10000)+p2.x);
::SendMessageW(gameh,WM_LBUTTONDOWN,0,lMousePos);
Sleep(100);
::SendMessageW(gameh,WM_LBUTTONUP,0,lMousePos);
return 0;
}
同问!!!!!!!!!!!!!!
页:
[1]