1,183
社区成员
发帖
与我相关
我的任务
分享
function DoEvents:Bool;
var
aMsg:TMsg;
begin
while PeekMessage(aMsg,0,0,0,PM_REMOVE) do begin
if(aMsg.message = WM_QUIT) then begin
Result:=False;
Exit;
end;
TranslateMessage(aMsg);
DispatchMessage(aMsg);
end;
Result:=True;
end;
procedure WaitTime(const iSec:DWORD);
var
iTimeOut:DWORD;
begin
iTimeOut:=GetTickCount + iSec ;
while (iTimeOut > GetTickCount) do begin
Sleep(1);
if not DoEvents then Break;
end;
end;
procedure MouseMovePos(lPoint:TPoint);
var
fPoint:TPoint;
begin
GetCursorPos(fPoint);
while not((fPoint.X=lPoint.X) and (fPoint.Y=lPoint.Y)) do begin
if fPoint.X>lPoint.X then Dec(fPoint.X);
if fPoint.X<lPoint.X then Inc(fPoint.X);
if fPoint.Y>lPoint.Y then Dec(fPoint.Y);
if fPoint.Y<lPoint.Y then Inc(fPoint.Y);
SetCursorPos(fPoint.X, fPoint.Y);
WaitTime(1);
end;
SetCursorPos(fPoint.X, fPoint.Y);
end;
///////////////////////
//使用
var
lPoint:TPoint;
begin
lPoint.x:=10;
lPoint.y:=10;
MouseMovePos(lPoint);
mouse_event(MOUSEEVENTF_LEFTDOWN,0,0,0,0);
WaitTime(1);
mouse_event(MOUSEEVENTF_LEFTUP,0,0,0,0);
end;