Sign in to follow this  
Followers 0
brett

Randomize Pausing

5 posts in this topic

how would i make my program pause until a certain key - or key combination - that is randomly generated, is pressed?


-Brett

Share this post


Link to post
Share on other sites



1. Click here

2. Under Search by Keywords, type pause

3. Press the button marked "Perform the search".

This will search the Support forum for similar requests, and might give you quite a few ideas.

Hope this helps :D

Share this post


Link to post
Share on other sites

Or simply

Func RandomSleep($PauseMin,$PauseMax)
Local $Pause
If $PauseMin <= $PauseMax Then
   $Pause = Int(Random($PauseMin,$PauseMax + 1)) * 1000
   Sleep($pause)
EndIf
EndFunc;<== RandomSleep End

Append this at the end of your source and call the random pause as function.

Share this post


Link to post
Share on other sites

i dont mean that it is paused for a random amount of time, i mean that it is paused until a certain key is pressed...for example the random key it generates is "W", so this would pause until "W" is pressed.


-Brett

Share this post


Link to post
Share on other sites

I'm new to AutoIt, so you'll have to make due with partial code:

You fill an array with strings of the keys you want to be randomly chosen.

Where n is number of keys you wish to choose from:

Dim $array[n]

$array[0] = "B"

$array[1] = "{DOWN}"

...

...

$array[n] = "{ESC}"

Then generate a random number between 0 and n:

Dim $rn = Int(Random() * n)

then set a hot key

HotKeySet($array[$rn], "hotkeyfunc")

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