Reputation: 11
To start off, I am a big noob when it comes to AHK.
When I want to sleep a random amount of seconds with this variable: random rand, 0, 3000 it always sleeps for 3000. I can't figure out why. I've searched on multiple forums but most of the times the code provided in the slolution is too complicated for me to understand. Sidenote: Do you guys know of any good youtube tutorial series aimed at beginners?
I followed the exact steps from this comment:
This is my code:
pause on
random rand, 0, 3000
mousemove, 100,100,20,r
sleep %rand%
mousemove, 100,100,20,r
sleep %rand%
mousemove, 100,100,20,r
sleep %rand%
mousemove, 100,100,20,r
sleep %rand%
return
z:: pause
x:: exitapp
c:: return
The mousemove
is just a placeholder to test the random sleeping. Between every 0 and 3 seconds randomly I expect the mouse to move. Now it only does it every 3 seconds exactly.
Lastly: As I am new to stack overflow, so If you can give me some suggestions to format my post better feel free to do so.
Thanks!
Upvotes: 0
Views: 2423
Reputation: 11
After some more googling and help from a friend, I'm now with the following code: It seems to work now, and it's also looped 50 times. Recommendations to improve the code are welcome.
pause on
rnd(min,max){
Random, myVar,% min,% max
return myVar
}
loop
{
if x >=50
break
else
mousemove, 100, 100, 10, r
Sleep, % rnd(1,2000)
x++
}
Return
z:: pause
x:: exitapp
c:: return
Upvotes: 1