delphi 在桌面屏幕上模拟鼠标单击
procedure TFrmUnicom.Button1Click(Sender: TObject);
var
oldPoint, newPoint: TPoint;
begin
GetCursorPos(&oldPoint); // 保存当前鼠标位置。
newPoint.x := 1050;
newPoint.y := 325;
MouseClick(newPoint); // 模拟放开鼠标左键。
application.ProcessMessages;
sleep(1000);
application.ProcessMessages;
newPoint.x := 1050;
newPoint.y := 747;
MouseClick(newPoint); // 模拟放开鼠标左键。
end;
procedure TFrmUnicom.MouseClick(newPoint: TPoint);
begin
SetCursorPos(newPoint.x, newPoint.y);
// 设置目的地位置。
mouse_event(MOUSEEVENTF_RIGHTDOWN, 0, 0, 0, 0);
// 模拟按下鼠标右键。
mouse_event(MOUSEEVENTF_RIGHTUP, 0, 0, 0, 0);
// 模拟放开鼠标右键。
mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0);
// 模拟按下鼠标左键。
mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0);
end;
Copyright © 2014 DelphiW.com 开发 源码 文档 技巧 All Rights Reserved
晋ICP备14006235号-8 晋公网安备 14108102000087号
执行时间: 0.04186487197876 seconds