Jump to content
supbro123

A random X or Y cord

Recommended Posts

Hey thanks for the help

 

So basically I have this script that I just found again that auto-clicks after every random time. Originally this was a script where you put in the location you want it to click and so forth. However me being the expert I tend to be I changed it so it would click wherever the current mouse position is.

 

But now I want it get the current mouse position, and then add some random distance from the current mouse position. So if the X cord currently was 5, I want it to have 5 + 1,10 "distance". This would just help create some randomness of where it would click. I know this is not the best explanation but I hope you get the general idea.

 

Was wondering if anyone had any clue on how to do so

 

Thanks!

Link to comment
Share on other sites

2 ways to go about this. First is to get the mouse position, generate random numbers and then move the mouse with random numbers added on :

 

var x,y,randx,randy:integer;

begin
 repeat
     GetMousepos(x,y);
   while GetMouseBtnState(mbLeft) do  
     begin
       Randx := randomrange(-10,10);
       Randy := randomrange(-10,10);           
       movemouse(x+randx,y+randy);
       writeln('X: '+ inttostr(X+RandX)+' Y: '+inttostr(Y+RandY)); 
     end;  
 until GetMouseBtnState(mbRight);
end.

 

The second way is just to have your mouse move within a boxed area

 

var x,y,PosX,PosY:integer;

begin
 repeat
   GetMousepos(x,y);  
   while GetMouseBtnState(mbLeft) do  
     begin
       MoveMouseBox(Box(x-50, y-50, x+50, y+50));
       GetMousepos(Posx,Posy);
       writeln('Moved the Mouse to X: '+ inttostr(PosX)+' Y: '+inttostr(PosY)); 
     end;  
 until GetMouseBtnState(mbRight);
end.

 

In both script cases whenever you hit the left mouse button it will move around randomly at that spot. Right click ends the script. Hope this helps.

Edited by Oort
Link to comment
Share on other sites

MouseBox method didn't seem to work, but the first one did and I also understood where you were coming from. But now I am lost as to how I make the procedure repeat. Is this the outline?

 

procedure Click;

begin

_____

end;

 

begin

Click;

end.

 

- - - Updated - - -

 

I think the MouseBox error might have been due to me using v3.22

Link to comment
Share on other sites

Ahh funny that, never looked it that way.

 

From the looks of it, it seems to be working smoothly. So now it will go to a random spot from within the set coordinates and click with random intervals. And once the number of clicks are greater than a random number between 5-155, the procedure Click is started again with a new set of x and y. Trying to keep it all random.

 

Thank you guys for the help and I will most likely try make a simple one later on seeing as how I enjoyed this.

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...