我有一个Delphi表格,上面有一个带有谷歌地图的TWebbroser。我想模拟鼠标拖动。左键单击,将鼠标移动到另一个位置,释放鼠标。它应该从左到右拖动地图。 我试过这个,但地图没有拖动。
procedure MoveMouse (X,Y,Speed: Integer);
var
Maus : TPoint;
mx, my, nx, ny, len : double;
begin
mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0);
if Speed < 1 then Speed := 1;
GetCursorPos(Maus);
mx := maus.x;
my := maus.y;
While (mx<>x)OR(my<>y) Do begin
nx := x-mx;
ny := y-my;
len := sqrt(nx*nx + ny*ny);
if(len<=1)Then begin
mx:=x;
my:=y;
end
else begin
nx := nx / (len*0.5);
ny := ny / (len*0.5);
mx := mx + nx;
my := my + ny;
end;
Mouse_Event(MOUSEEVENTF_ABSOLUTE, Round(mx)+50,Round(my), 0, GetMessageExtraInfo);
// SetCursorPos(Round(mx),Round(my));
Sleep(Speed);
end;
mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0);
end;
拜托,有人可以帮帮我吗?非常感谢!