Jump to content

Sleeping for random amount of time


Guest rcm87
 Share

Recommended Posts

Guest rcm87

I would like autoit to send a character, sleep for a random amount of time between 2 set times. So pick a random time beteen 10 seconds and 15 seconds and send a character. I am a brand new script writer so this could be pretty simple. It looks like to me they sleep is looking for an int and not a value. Here is what I have so far. Thanks for the help.

$timeleft = 28
While $timeleft > 0

$sleeping = Random(50000 , 10000)
Send ("2") 
sleep = $sleeping;  ;<--errors out here

$timeleft = $timeleft - 1
Link to comment
Share on other sites

sleep = $sleeping;  ;<--errors out here

It should be $sleep = $sleeping

It seem like you are just miss the $ symbol in font of sleep :ph34r:

nope, it was that he wanted sleep to be the command, and $sleeping to be the variable used by it. this would do that:

$timeleft = 28
While $timeleft > 0

$sleeping = Random(50000 , 10000)
Send ("2")
sleep($sleeping)

$timeleft = $timeleft - 1
wend;- this was missing

of course, Larry's does the same thing while saving the use of a variable that's not needed, unless $sleeping will be reused at some point later?

"I'm not even supposed to be here today!" -Dante (Hicks)

Link to comment
Share on other sites

sleep = $sleeping;  ;<--errors out here

It should be $sleep = $sleeping

It seem like you are just miss the $ symbol in font of sleep :ph34r:

emmanuel is correct. I was using sleep as the command in that example and in my tests it works. $c is the variable in which the random number will be placed. I did make a mistake by using 10 and 15 in that example, and it should be 10000 and 15000 because 5000 is just 5 seconds. Edited by autoitNOW
An ADVOCATE for AutoIT
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...