请教:如何编程控制鼠标自动点击屏幕指定的位置坐标?(100分)

  • 主题发起人 主题发起人 love
  • 开始时间 开始时间
L

love

Unregistered / Unconfirmed
GUEST, unregistred user!
如何编程控制鼠标自动点击屏幕指定的位置坐标?请专家回答
 
可以模拟一下,用SetCursorPos将鼠标自动移到指定的位置,再执行
相应的函数。
 
mouse_event(MOUSEEVENTF_MOVE,100,100,0,0);
mouse_event(MOUSEEVENTF_LEFTDOWN,0,0,0,0);
mouse_event(mouseeventf_leftup,0,0,0,0);
 
mouse_event(MOUSEEVENTF_MOVE,100,100,0,0);
mouse_event(MOUSEEVENTF_LEFTDOWN,0,0,0,0);
mouse_event(mouseeventf_leftup,0,0,0,0);
 
mouse_event(MOUSEEVENTF_MOVE,100,100,0,0);
确定的(100,100)是相对于当前鼠标位置的,因而采用这种
方法很不好控制到向要点击的位置.
SetCursorPos(X,Y)是相对于整个屏幕的,可用
SetCursorPos(Left+Image1.Left,Top+20+Image1.Top)来
确定鼠标位置其中top+20是留出窗口标题栏.
我的测试程序如下:
procedure TForm1.Button1Click(Sender: TObject);
begin
SetCursorPos(Left+Image1.Left+10,Top+20+Image1.Top+10);
Mouse_event(MOUSEEVENTF_LEFTDOWN,0,0,0,0);
Mouse_event(mouseeventf_leftup,0,0,0,0);
end;
Image的OnClick事件被调用了.

 
define a block , if the position you want to point in the block, the
event takes place . the size of the block is defined according to the
pricise you need.
 
mouse_event(MOUSEEVENTF_MOVE,100,100,0,0);
mouse_event(MOUSEEVENTF_LEFTDOWN,0,0,0,0);
mouse_event(mouseeventf_leftup,0,0,0,0);
 
mouse_event(MOUSEEVENTF_MOVE,100,100,0,0);
mouse_event(MOUSEEVENTF_LEFTDOWN,0,0,0,0);
mouse_event(mouseeventf_leftup,0,0,0,0);
 
同意yaoyao
 
大家的方法都可以用
to love:你如果嫌麻烦的话可以到
http://202.103.176.81/frun/shangrw/下载一个有关鼠标动作的控件.
 
接受答案了.
 
后退
顶部