一个简单的发送消息问题(50分)

  • 主题发起人 主题发起人 andy263
  • 开始时间 开始时间
A

andy263

Unregistered / Unconfirmed
GUEST, unregistred user!
比如我想自动点一下windows扫雷的某一个点 写了如下程序:<br>var<br>&nbsp; hMine: HWND;<br>&nbsp; pos: Word;<br>&nbsp; xPos, yPos: integer;<br>&nbsp; pt: TPoint;<br>begin<br>&nbsp; hMine := FindWindow('扫雷', '扫雷');<br>&nbsp; if hMine = 0 then exit;<br>&nbsp; wordrec(pos).lo := 1; //X位置<br>&nbsp; wordrec(pos).hi := 1; //Y位置<br><br>&nbsp; SendMessage(hMine, WM_LBUTTONDOWN, 0, pos);<br>// &nbsp;SendMessage(hMine, WM_LBUTTONUP, 0, pos);<br>----------------------------------------------------<br>这样当我执行到这个事件的时候 扫雷窗体会有反映(小人张大嘴巴) 但是我取消掉最后一个注释想实现自动点雷的时候却没有任何反映。无论我怎样修改x,y的都不行。请问这是为什么?
 
这样就可以了,我刚试过。<br>&nbsp;hMine := FindWindow('扫雷', '扫雷');<br>&nbsp;if hMine = 0 then exit;<br>&nbsp;SendMessage(hMine, WM_LBUTTONDOWN, HTClient, MakelParam(100,100));<br>&nbsp;SendMessage(hMine, WM_LBUTTONUP, HTClient, MakelParam(100,200));
 
多谢多谢!!!
 
我这个可以,你对比一下,看什么地方有问题<br>var<br>&nbsp;hMine: HWND;<br>&nbsp;npos: Integer;<br>&nbsp;xPos, yPos: integer;<br>&nbsp;pt: TPoint;<br>begin<br>&nbsp;hMine := FindWindow(nil, '扫雷');<br>&nbsp;if hMine = 0 then exit;<br>&nbsp;xPos :=StrToInt(Copy(Edit1.Text,1,Pos(',',Edit1.Text)-1));<br>&nbsp;yPos :=StrToInt(Copy(Edit1.Text,Pos(',',Edit1.Text)+1,Length(Edit1.Text)));<br>&nbsp;npos :=yPos shl 16 + xPos;<br>&nbsp;SetForegroundWindow(hMine);<br>&nbsp;SendMessage(hMine, WM_LBUTTONDOWN, 0, npos);<br>&nbsp;SendMessage(hMine, WM_LBUTTONUP, 0, npos);
 
后退
顶部