Adding random number to mouse click

Hints, tips and tricks for newbies

Moderators: Dorian (MJT support), JRL

Post Reply
Sandergutt
Newbie
Posts: 2
Joined: Fri Oct 05, 2018 8:51 pm

Adding random number to mouse click

Post by Sandergutt » Fri Oct 05, 2018 9:06 pm

Hi, I see this question some other places but cant seem to get it to work.

I have recorded a macro and want to add a random number to the "MouseMove" coordinates.

This is part of my script:

Code: Select all

//Recorded Events
CapsOff
MouseMove>360,673
Wait>2.912
LClick
Wait>1.265
MouseMove>443,729
Wait>0.916
LClick
Wait>0.875
MouseMove>532,668
Wait>0.898
LClick
I simply want to add a random 10 pixle to the coordinates. So that it moves from every click.
The app i try to use is looking for bots and by pressing the exact same place twice it restarts the app (even if i click elsewhere in between).
I'm guessing this is how it is detecting it.

Anyhow. I just want to add a random number to the coordinates.
Can anyone help out and show me directly in the script? I just dont understand the posts i found about this on the forum.

Thanks in advance.

User avatar
Marcus Tettmar
Site Admin
Posts: 7003
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Re: Adding random number to mouse click

Post by Marcus Tettmar » Sat Oct 06, 2018 11:43 am

Use the Random function to get a random number within a specified range, use the result as an offset to apply to the MouseMove:

Code: Select all

//starting point
Let>x=360
Let>y=670

//let's get a random offset between -5 and +5
Random>11,offset
Let>offset=offset-5

//new point:
Let>x=x+offset
Let>y=y+offset

//move the moust
MouseMove>x,y
Presumably you might want this in a loop. A very simple but never-ending loop would be:

Code: Select all

//starting point
Let>x=360
Let>y=670

//put it in a loop?
Label>moveTheMouse

//let's get a random offset between -5 and +5
Random>11,offset
Let>offset=offset-5

//new point:
Let>x=x+offset
Let>y=y+offset

//move the moust
MouseMove>x,y

Wait>0.5
Goto>moveTheMouse
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

Sandergutt
Newbie
Posts: 2
Joined: Fri Oct 05, 2018 8:51 pm

Re: Adding random number to mouse click

Post by Sandergutt » Tue Oct 09, 2018 8:44 pm

Thank you so much for this. I went another route with it, and instead of clicking different places i just moved the whole window before each script cycle. Even then the random wasn't random enough so i run the script 2 times and made a set change between then.
Messy, but here is my final script which works as intended:

Code: Select all

Label>FromTheStart
//starting point
Let>x=225
//let's get a random offset between -5 and +5
Random>20,offset
Let>offset=offset-10
//new point:
Let>x=x+offset
//move the moust
//MouseMove>x,y

Let>WW_TIMEOUT=5
CapsOff
WaitWindowOpen>Window1
MoveWindow>Window1,x,1
ResizeWindow>Window1,465,801
MouseMove>349,657
Wait>1.385
LClick
Wait>1.25
MouseMove>451,730
Wait>1.146
LClick
Wait>1.687
MouseMove>549,664
Wait>1.347
LClick
Wait>0.891
MouseMove>589,663
Wait>0.922
LClick
Wait>0.734
MouseMove>548,663
Wait>0.823
LClick
Wait>1.968
MouseMove>470,651
Wait>3.692
Press Esc
Press Esc
-----------------
//Loop 2
-----------------
//starting point
Let>x=241
//let's get a random offset between -5 and +5
Random>20,offset
Let>offset=offset-10
//new point:
Let>x=x+offset
//move the moust
//MouseMove>x,y


Let>WW_TIMEOUT=5
CapsOff
WaitWindowOpen>Window1
MoveWindow>Window1,x,6
ResizeWindow>Window1,465,801
MouseMove>349,657
Wait>1.385
LClick
Wait>1.25
MouseMove>451,730
Wait>1.146
LClick
Wait>1.687
MouseMove>549,664
Wait>1.347
LClick
Wait>0.891
MouseMove>589,663
Wait>0.922
LClick
Wait>0.734
MouseMove>548,663
Wait>0.823
LClick
Wait>1.968
MouseMove>470,651
Wait>3.692
Press Esc
Press Esc

Goto>FromTheStart

Post Reply