You can use MouseBack
SCAR Code:
{*******************************************************************************
procedure MouseBack(cx, cy, RanX, RanY, RandomEnd, PercentReturn, Click: Integer);
By: phantombmx
Description: Like MMouse or Mouse but will fall back on the starting point.
RandomEnd is a random for the total ending point, 50 is good. PercentReturn is the
percentage that it will fall back, 50-70 is good. 0 for no click, 1 for left, 2 for right.
*******************************************************************************}
procedure MouseBack(cx, cy, RanX, RanY, RandomEnd, PercentReturn, Click:
Integer);
var
fx1, fx2, fy1, fy2: Integer;
perc: Extended;
begin
perc := StrToFloat(IntToStr(PercentReturn)) / 100
GetMousePos(fx1, fy1);
case Click of
0: MMouse(cx, cy, RanX, RanY);
1: Mouse(cx, cy, RanX, RanY, True);
2: Mouse(cx, cy, RanX, RanY, False);
end;
GetMousePos(fx2, fy2);
if (Min(fx1, fx2) = fx1) then
fx1 := fx2 - Trunc((fx2 - fx1) * (perc))
else
fx1 := fx1 + Trunc((fx1 - fx2) * (perc));
if (Min(fy1, fy2) = fy1) then
fy1 := fy2 - Trunc((fy2 - fy1) * (perc))
else
fy1 := fy1 + Trunc((fy1 - fy2) * (perc));
case Random(2) of
0: MMouse(fx1 - Random(RandomEnd), fy1 - Random(RandomEnd), 0, 0);
1: MMouse(fx1, fy1, RandomEnd, RandomEnd);
end;
end;