Sign in to follow this  
Followers 0
vickerps

sleep until

5 posts in this topic

Hi

Is there a way to pause a script for say 60 seconds but if the user presses a key (for example 'Esc') within the 60 seconds the script would abort the pause and continue with what ever left to do in the script.

Share this post


Link to post
Share on other sites



Try this:

HotKeySet("e", "_MyCode")
Sleep(60000)
Func _MyCode()
;Whatever code you want here..
    MsgBox(0, "whatever", "whatever"); don't need the msgbox, just for debugging purposes
    Exit
EndFunc

FootbaG

Share this post


Link to post
Share on other sites

From the FM:

Function Reference

MsgBox

--------------------------------------------------------------------------------

Displays a simple message box with optional timeout.

MsgBox ( flag, "title", "text" [, timeout])

msgbox(4096,"Choose","Click when ready",60)

...by the way, it's pronounced: "JIF"... Bob Berry --- inventor of the GIF format

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Try this, it goes in 1-second increments but it is trivial to change that:

HotKeySet("^c", "ContinueFunc")

...

$keepgoing = 0
$timer = 0
Do
   Sleep(1000)
   $timer = $timer + 1
Until($keepgoing Or ($timer = 60))

...

Func ContinueFunc()
   $keepgoing = 1
EndFunc
Edited by Christopher Blue

Share this post


Link to post
Share on other sites

From the FM:

msgbox(4096,"Choose","Click when ready",60)

That's the method I would use, however, a little expansion

$i_Return = MsgBox(4096, "Choose", "Click when ready", 60)
 If $i_Return = -1 Then Exit

If MsgBox times out, returns -1, that's where the if-statement comes in, else it will continue the script


Writing AutoIt scripts since
_DateAdd("d", -2, _NowCalcDate())

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