Simba Code:
{*******************************************************************************
Procedure windTrackingMouse();
By: Flight & bg5
Description (Flight): Mouse movement based on distance to determine speed. Default slowed
speed at 20% from destination, if Double is set to true then slowed
speed also starts at origin and ends 80% to destination.
Description (bg5): Variation of Flight's brakeWindMouse from aerolib. Calls function
(returning address to TPoint) every refreshingDelay seconds to update destination.
That function must be wrapped properly!
All changes are marked with //*
*******************************************************************************}
Procedure windTrackingMouse(xs, ys, gravity, wind, minWait, maxWait,
targetArea: extended; double: boolean;
funcRetTPointAdr:string; args:TVariantArray; refreshingDelay :integer ); //*
var
T,rD : Timer; //*
xe, ye , ap :integer; //*
Pe :TPoint; //*
veloX,veloY,windX,windY,veloMag,dist,randomDist,lastDist,D: extended;
lastX,lastY,MSP,W,TDist: integer;
sqrt2,sqrt3,sqrt5,PDist,maxStep,dModA,dModB,nModA,nModB: extended;
begin
ap := VariantInvoke(funcRetTPointAdr,args); // *
Pe := TPoint(Pointer(ap)^); // *
xe := Pe.X; //*
ye := Pe.y; //*
rD.start(); //*
MSP := MouseSpeed;
sqrt2:= sqrt(2);
sqrt3:= sqrt(3);
sqrt5:= sqrt(5);
TDist := Distance(Round(xs), Round(ys), Round(xe), Round(ye));
if (TDist < 1) then
TDist := 1;
dModA := 0.88;
dModB := 0.95;
if (TDist > 220) then
begin
nModA := 0.08;
nModB := 0.04;
end else if (TDist <= 220) then
begin
nModA := 0.20;
nModB := 0.10;
end;
T.start();
repeat
if (T.timeElapsed() > 10000) then
break;
if (rd.timeElapsed() > refreshingDelay) then //*
begin
ap := VariantInvoke(funcRetTPointAdr,args); // *
Pe := TPoint(Pointer(ap)^); // *
xe := Pe.X; //*
ye := Pe.y; //*
rD.start(); //*
end;
dist:= hypot(xs - xe, ys - ye);
wind:= minE(wind, dist);
if (dist < 1) then
dist := 1;
PDist := (dist/TDist);
if (PDist < 0.01) then
PDist := 0.01;
if Double then
begin
if (PDist <= dModA) then
begin
D := (Round((Round(dist)*0.3))/5);
if (D < 20) then
D := 20;
end else if (PDist > dModA) then
begin
if (PDist < dModB) then
D := RandomRange(5, 8)
else if (PDist >= dModB) then
D := RandomRange(3, 4);
end;
end;
if (PDist >= nModA) then
begin
D := (Round((Round(dist)*0.3))/5);
if (D < 20) then
D := 20;
end else if (PDist < nModA) then
begin
if (PDist >= nModB) then
D := RandomRange(5, 8)
else if (PDist < nModB) then
D := RandomRange(3, 4);
end;
if (D <= Round(dist)) then
maxStep := D
else
maxStep := Round(dist);
if dist >= targetArea then
begin
windX:= windX / sqrt3 + (random(round(wind) * 2 + 1) - wind) / sqrt5;
windY:= windY / sqrt3 + (random(round(wind) * 2 + 1) - wind) / sqrt5;
end else
begin
windX:= windX / sqrt2;
windY:= windY / sqrt2;
end;
veloX:= veloX + windX;
veloY:= veloY + windY;
veloX:= veloX + gravity * (xe - xs) / dist;
veloY:= veloY + gravity * (ye - ys) / dist;
if (hypot(veloX, veloY) > maxStep) then
begin
randomDist:= maxStep / 2.0 + random(round(maxStep) div 2);
veloMag:= sqrt(veloX * veloX + veloY * veloY);
veloX:= (veloX / veloMag) * randomDist;
veloY:= (veloY / veloMag) * randomDist;
end;
lastX:= Round(xs);
lastY:= Round(ys);
xs:= xs + veloX;
ys:= ys + veloY;
if (lastX <> Round(xs)) or (lastY <> Round(ys)) then
moveMouse(Round(xs), Round(ys));
W := (Random((Round(100/MSP)))*6);
if (W < 5) then
W := 5;
if Double then
if (PDist > dModA) then
W := Round(W*2.5)
else
W := Round(W*1.2);
wait(W);
lastdist:= dist;
until(hypot(xs - xe, ys - ye) < 1)
if (Round(xe) <> Round(xs)) or (Round(ye) <> Round(ys)) then
MoveMouse(Round(xe), Round(ye));
MouseSpeed := MSP;
end;
{*******************************************************************************
By: Flight & bg5
Description(Flight): Makes use of BrakeWindMouse; mouse speed decreases at 15% to
destination point. If Double is set to true then speed starts
slow and increases through the first 15% of the path.
Description (bg5): Variation of Flight's brakeMMouse from aerolib. Calls function
(returning address to TPoint) every refreshingDelay seconds to update destination.
That function must be wrapped properly!
All changes are marked with //*
*******************************************************************************}
Procedure TrackMMouse(double: Boolean; //* randomization of destination point not needed
funcRetTPointAdr:string; args:TVariantArray; refreshingDelay :integer); //*
var
randSpeed : extended;
X,Y,MS : integer;
begin
MS := MouseSpeed;
randSpeed := (random(MouseSpeed) / 2.0 + MouseSpeed) / 10.0;
getMousePos(X, Y);
windTrackingMouse(X, Y, //*
8, 3, 10.0/randSpeed, 15.0/randSpeed, 10.0*randSpeed, double,
funcRetTPointAdr,args,refreshingDelay); //*
MouseSpeed := MS;
end;
Simba Code:
function TReflectGroundItem.Grab2() :boolean;
begin
{...}
TrackMMouse(TRUE,'Wrap_TReflectGroundItem_GetMSPoint',
[integer(@self),integer(@res_Wrap_TReflectGroundItem_GetMSPoint)], 100);
Reflect.Mouse.Click(Mouse_Right);
if Reflect.Text.ChooseOption(self.GetName,50) then
begin
Result := TRUE;
break;
end;
{..}
end;