wie schaffe ich es denn mit folgendem code den cursor über ein control zu platzieren?
Delphi-Quellcode:
procedure MoveMouse(X, Y, Speed: Integer);
var
Maus: TPoint;
mx, my, nx, ny, len: double;
begin
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;
SetCursorPos(Round(mx), Round(my));
Sleep(Speed);
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
MoveMouse(Button2.Left, Button2.Top, 10);
end;