• Sky
• Blueberry
• Slate
• Blackcurrant
• Watermelon
• Strawberry
• Orange
• Banana
• Apple
• Emerald
• Chocolate
• Charcoal

# 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!

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

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

##### Share on other sites

Oort already gave you an example in his code with the repeat statement.

```repeat
<DoSomething>
until <SomeConditionIsTrue>;```

To have it repeat forever

```repeat
Click;
until False;  // Will never be true```

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

##### Share on other sites

Good to hear you got it going! I find scripting adds to a games re playability and decreases the mind numbing of redundant operations. Just getting the scripts to work is almost like a game unto itself

## Join the conversation

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

×   Pasted as rich text.   Paste as plain text instead

Only 75 emoji are allowed.

×   Your previous content has been restored.   Clear editor

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

×

×