SRL Archive - SRL Snippets

Another mouse move function


CynicRus

2013-01-23 13:30:31

Hey. I present to you a simple implementation of the function the mouse movement.
Maybe it would be useful to someone.

program SimplyMouse;

function randomFloat(aMin,aMax:double):double;
begin
result:=randomRange(trunc(aMin*1000),trunc(aMax*1000))/1000
end;

procedure SimplyMouseMove(StartPt,EndPt:TPoint;Direct: boolean);
var
nmouseX,nMouseY: integer;
incX,incY: double;
begin
incX:=(EndPt.x - StartPt.x)/(EndPt.y - StartPt.y);
incY:= (EndPt.y - StartPt.y)/(EndPt.x - StartPt.x);
nmouseX:=StartPt.x;
nmouseY:=StartPt.y;
if Direct then
repeat
nmouseX:=nmouseX+Trunc(incX);
nmouseY:=nmouseY+Trunc(incY);
MoveMouse(nmouseX,nmouseY);
Wait(RandomRange(1,6));
until (nmouseX >= EndPt.x) Or (nmouseY>= EndPt.y)
else
repeat
nmouseX:=nmouseX+round(incX*randomFloat(0.5,1.5));
nmouseY:=nmouseY+round(incY*randomFloat(0.5,1.5));
MoveMouse(nmouseX,nmouseY);
Wait(RandomRange(1,6));
until (nmouseX >= EndPt.x) Or (nmouseY>= EndPt.y);
end;


begin
SimplyMouseMove(Point(20,20),Point(60,230),false);
end.

Cheers,
Cynic.

i luffs yeww

2013-01-23 14:21:27

Few things.

One, your example only moves on the y-axis. It's actually a bit difficult to get it to move on both axes - it will usually only move on one axis or the other.

There's also a divide-by-zero error if you try to have either x or y be on the same point for start and end.

But I'm sure you can fix those. :)

Rich

2013-01-23 14:24:45

Sorry if I'm being thick, but doesn't this do the same as MoveMouseSmooth?

CynicRus

2013-01-23 14:26:26

Honestly do not know, I convert it from my old bot code on EasyUO:)

tristen8878

2013-01-23 14:48:23

I have been wondering whether it would be possible to use flights humanmmouse but add pauses and change of mouse speed when going from point A to B if you get what I mean.

I will try this out later when am at home.