Jump to content
slacky

Mouse movement in OSI - Another way.

Recommended Posts

Hello. I wanted to see what you guys mean about this wierd mouse-moving function? :P It very simple, so, pretty much the first thing i've ported to Pascal in many many years! :P

 

It purely condition based, no real math involved, it moves. The speed will differ according to it's angle (and distance).

 

Speed might need some adjustment (Wait time at the end), and it could be made more randomized, and "smarter".. :)

procedure SimpleMouse(x,y:Integer);
var wx,wy,px,py,ax,ay:Integer;
begin
 GetMousePos(wx, wy);
 repeat
   if(y>wy) and (x>wx) Then begin px:=x-wx; py:=y-wy; end;
   if(y<wy) and (x>wx) Then begin px:=x-wx; py:=wy-y; end;
   if(y<wy) and (x<wx) Then begin px:=wx-x; py:=wy-y; end;
   if(y>wy) and (x<wx) Then begin px:=wx-x; py:=y-wy; end;
   if(y>wy) and (x=wx) Then begin px:=x; py:=y-wy; end;
   if(y<wy) and (x=wx) Then begin px:=x; py:=wy-y; end;
   if(x<wx) and (y=wy) Then begin px:=x-wx; py:=y; end;
   if(x>wx) and (y=wy) Then begin px:=wx-x; py:=y; end;     

   if(px>py) and (px<>0) and (py<>0) Then begin ax:=round(px div py); ay:=1; end;
   if(px<py) and (px<>0) and (py<>0) Then begin ay:=round(py div px); ax:=1; end;
   if(px=py) or (px=0) or (py=0) Then begin ax:=1; ay:=1; end;

   if(wx<x) Then wx:=wx+ax;
   if(wy<y) Then wy:=wy+ay;
   if(wx>x) Then wx:=wx-ax;
   if(wy>y) Then wy:=wy-ay;

   MoveMouse(wx,wy)
   wait(3+Random(3))
 until(wx=x) and (wy=y);
end; 

 

Meh.. ;-P

Edited by slacky
meh
Link to comment
Share on other sites

@shadowrecon: Not all that correct. It will not work at only 45 degrees, it will always reach its destination. But my it was hard making it work correct i pascal, i had to change a lot of stuff. I might update it with a fix. It HAD a problem with moving 0 degrees.//Fixed

 

The final point is not randomized, this can be easly done.

 

Edit: Fixed, it became somewhat "long" since i do not know how to formulate it in pascal, and the math is ugly (Though it's correct).

- My bot has been running this for 2 hours, so it should be fine.

Edited by slacky
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
  • Create New...