Registriert seit: 26. Aug 2004
Ort: Nebel auf Amrum
3.154 Beiträge
Delphi 7 Enterprise
|
AW: Mausbewegung(!) simulieren
15. Apr 2012, 17:39
Vielleicht so...
Delphi-Quellcode:
procedure MoveMouse(X, Y, Speed: Cardinal);
var
Maus: TPoint;
mx, my, nx, ny, len: double;
begin
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;
SetCursorPos(Round(mx), Round(my));
Sleep(Speed);
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
var P:TPoint;
begin
P:=Self.ClientToScreen(Point(
Button2.Left + (Button2.Width div 2),
Button2.Top + (Button2.Height div 2)
));
MoveMouse(P.X, P.Y, 10);
end;
|
|
Zitat
|