Jump to content
Sign in to follow this  
AC130

Stop Sleep

Recommended Posts

AC130

How do you stop a long period of sleep?

For instance:

Sleep(5000)

What If I want to interrupt that sleep? I tried Sleep(1), but that didn't work. Maybe I can put sleep in a Do/Loop and declare a function that stops the loop? It would work, but I think there maybe other ways to achieve my goal. Any ideas?

Share this post


Link to post
Share on other sites
AZJIO

Show task, and not something as you try to solve it. Set a smaller size sleep before you start function. You can run "Sleep" several times.

Global $TrgStop = 0

HotKeySet("^1", "_Reset")
Func _Reset()
    $TrgStop = 1
EndFunc

_Sleep(60000)
MsgBox(0, 'Yes?', '<img src='http://www.autoitscript.com/forum/public/style_emoticons/<#EMO_DIR#>/wink.png' class='bbc_emoticon' alt=';)' />')

Func _Sleep($iDelay, $iStep = 50)
    Local $iCount = Int($iDelay / $iStep)
    For $i = 1 To $iCount
        Sleep($iStep)
        If $TrgStop Then
            $TrgStop = 0
            ExitLoop
        EndIf
    Next
EndFunc
Edited by AZJIO

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  

×