Jump to content
Sign in to follow this  
brett

Randomize Pausing

Recommended Posts

brett

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
trids

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
ezzetabi

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
brett

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
Goutetsu

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.