Sign in to follow this  
Followers 0
lolp1

How do I make sleep random?

7 posts in this topic

I can't seem to find out how to randomize sleep between 4 mintues, and 4 1/2 mintues. Any help :P?

Share this post


Link to post
Share on other sites



I can't seem to find out how to randomize sleep between 4 mintues, and 4 1/2 mintues. Any help :P?

Sleep(Random(240000, 270000, 1))

[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

Thanks

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Thanks

Welcome, some simple math would have fixed it for you as well.

_SleepRandom(4, 4.5)

Func _SleepRandom($nMin1, $nMin2)
    Return Sleep(Random((Number($nMin1) * 60) * 1000, (Number($nMin2) * 60) * 1000, 1))
EndFunc

Edit:

Oops, I used $nMin1 for both.

Edited by SmOke_N

[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

couldn't you also assign a random variable and use that in the sleep command?

like sleep($var1) and then have the variable be a random number? Just wondering, might be more useful to make a variable if the statement is being used more than once in the program.

Share this post


Link to post
Share on other sites

couldn't you also assign a random variable and use that in the sleep command?

like sleep($var1) and then have the variable be a random number? Just wondering, might be more useful to make a variable if the statement is being used more than once in the program.

Your suggestion is no different than what I presented.

[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

Smoke_N's is just more refined then going

_SleepRandom(4, 4.5)

Func _SleepRandom($nMin1, $nMin2)
    $var1 = Random((Number($nMin1) * 60) * 1000, (Number($nMin2) * 60) * 1000, 1)
    Return Sleep($var1)
EndFunc

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0