PDA

View Full Version : Another mouse move function



CynicRus
01-23-2013, 06:30 PM
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*10 00))/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
01-23-2013, 07:21 PM
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
01-23-2013, 07:24 PM
Sorry if I'm being thick, but doesn't this do the same as MoveMouseSmooth?

CynicRus
01-23-2013, 07:26 PM
Honestly do not know, I convert it from my old bot code on EasyUO:)

tristen8878
01-23-2013, 07:48 PM
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.