Delphi编程模拟鼠标操作

Posted on 2008-07-21 13:14  白兴科技  阅读(808)  评论(0编辑  收藏  举报

procedure TForm1.Button1Click(Sender: TObject);
begin
  mouse_event(MOUSEEVENTF_MOVE,100,100,0,0); //移动鼠标

end;

procedure TForm1.Button3Click(Sender: TObject); //左键单击
begin
SetCursorPos(10,10);
mouse_event(MOUSEEVENTF_LEFTDOWN,0,0,0,0);
mouse_event(MOUSEEVENTF_LEFTUP,0,0,0,0);
end;

procedure TForm1.Button2Click(Sender: TObject);//左键双击
begin
SetCursorPos(200,200);
mouse_event(MOUSEEVENTF_LEFTDOWN,0,0,0,0);
mouse_event(MOUSEEVENTF_LEFTUP,0,0,0,0);
mouse_event(MOUSEEVENTF_LEFTDOWN,0,0,0,0);
mouse_event(MOUSEEVENTF_LEFTUP,0,0,0,0);

end;

procedure TForm1.Button4Click(Sender: TObject); //右键单击
begin
SetCursorPos(200,200);
mouse_event(MOUSEEVENTF_RIGHTDOWN,0,0,0,0);
mouse_event(MOUSEEVENTF_RIGHTUP,0,0,0,0);
end;

Copyright © 2024 白兴科技
Powered by .NET 9.0 on Kubernetes