postmessage的问题(200分)

  • 主题发起人 主题发起人 wind2000
  • 开始时间 开始时间
W

wind2000

Unregistered / Unconfirmed
GUEST, unregistred user!
最近在写个后台控制一游戏鼠标的小程序,移动鼠标有效,但点击无效(可能是游戏屏蔽了鼠标点击),有没有别的方法实现后台鼠标点击?<br>//移动有效<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Postmessage(hHdl, WM_MOUSEMOVE, MK_LBUTTON, MakeLong(iX, iY));<br>//点击无效<br>//左键<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; PostMessage(hHdl, WM_LBUTTONDOWN, MK_LBUTTON, 0);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; PostMessage(hHdl, WM_LBUTTONUP, MK_LBUTTON, 0);<br>//右键<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; PostMessage(hHdl, WM_RBUTTONDOWN, MK_RBUTTON, 0);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; PostMessage(hHdl, WM_RBUTTONUP, MK_RBUTTON, 0);
 
//试试这样。<br>//左键<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; PostMessage(hHdl, WM_LBUTTONDOWN, MK_LBUTTON, MakeLong(iX, iY));<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; PostMessage(hHdl, WM_LBUTTONUP, MK_LBUTTON, MakeLong(iX, iY));<br>//右键<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; PostMessage(hHdl, WM_RBUTTONDOWN, MK_RBUTTON, MakeLong(iX, iY));<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; PostMessage(hHdl, WM_RBUTTONUP, MK_RBUTTON, MakeLong(iX, iY));
 
试过了,一样无效。<br>谢谢观注。
 
你的游戏本身支不支持真实的鼠标点击的?如果不支持,那也就是没办法实现模拟鼠标点击了。如果支持,那上面的代码应该也有效,除非游戏Hook了相关的API
 
当然支持真实的鼠标点击了,游戏要不支持鼠标那还怎么玩啊,呵呵。。。<br>估计是后台模拟鼠标点击被屏蔽了,但后台模拟鼠标移动、模拟键盘又都可以。
 
刚又测了下,模拟按键中间加了适当的延时100-300微秒不等,一样不行<br>//移动有效,因为移到的位置是个按钮,鼠标移到那按钮会“加亮”,所以知道有效<br>&nbsp; &nbsp;Postmessage(hHdl, WM_MOUSEMOVE, MK_LBUTTON, MakeLong(iX, iY));<br>//用下面代码鼠标都不会移到按钮上,没任何反应<br>//左键<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; PostMessage(hHdl, WM_LBUTTONDOWN, MK_LBUTTON, MakeLong(iX, iY));<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Sleep(100); //Sleep(300);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; PostMessage(hHdl, WM_LBUTTONUP, MK_LBUTTON, MakeLong(iX, iY));<br>//右键<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; PostMessage(hHdl, WM_RBUTTONDOWN, MK_RBUTTON, MakeLong(iX, iY));<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Sleep(100); //Sleep(300);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; PostMessage(hHdl, WM_RBUTTONUP, MK_RBUTTON, MakeLong(iX, iY)); &nbsp;<br>我准备找下硬件模拟的方法试下。
 
if MouseControl.MouseControlType = MouseClick then<br>&nbsp; &nbsp; &nbsp; &nbsp; begin<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0);<br>&nbsp; &nbsp; &nbsp; &nbsp; end;<br>&nbsp; &nbsp; &nbsp; &nbsp; if MouseControl.MouseControlType = MouseDbClick then<br>&nbsp; &nbsp; &nbsp; &nbsp; begin<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0);<br>&nbsp; &nbsp; &nbsp; &nbsp; end;
 
to sbzldlb:<br>&nbsp; &nbsp;mouse_event只能对前台活动窗口有效,我要对后台的窗口进行操作。
 
后退
顶部