Jump to content

How do I make sleep random?


lolp1
 Share

Recommended Posts

  • Moderators

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

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.

Link to comment
Share on other sites

  • Moderators

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

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.

Link to comment
Share on other sites

  • Moderators

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.

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.

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...