Sign in to follow this  
Followers 0
onefish

Pause in script?

7 posts in this topic

Can anybody advise me of the best way to pause a script? I can't seem to fine anything in the help file or reference lists. I have used a counter and a loop that exits the loop after XX times. The more times that longer the pause. This doesn't seem right though. I thought about using the system clock but then the script will be dependant upon that functioning properly. What is the best way?

Share this post


Link to post
Share on other sites



Sleep(5000) ; Sleeps for 5 seconds



Get Beta versions Here Get latest SciTE editor Here AutoIt 1-2-3 by Valuater - A great starting point.

Time you enjoyed wasting is not wasted time ......T.S. Elliot
Suspense is worse than disappointment................Robert Burns
God help the man who won't help himself, because no-one else will...........My Grandmother

Share this post


Link to post
Share on other sites

And there's also the wait-for-user pause:

msgBox(0x40048, "Paused", "Press OK to continue.")

Share this post


Link to post
Share on other sites

or if you don't want it paused completely, You can do this.

$Pause = TimerInit()

Do
   Sleep(50)
Until TimerDiff($Pause) = 5000

That Pauses for 5 seconds as well.

Share this post


Link to post
Share on other sites

Just to elaborate on Knight's example: right now it's only equivalent to Sleep(5000) but its beauty lies in its ability to do things during that five seconds:

local $pause = timerInit()

do

    sleep(50)
    ; do some number crunching
    ; or perhaps search for some files

until (timerDiff($pause) = 5000)

Share this post


Link to post
Share on other sites

how to make it so its pause when it hit a key for example F12 and resume when it hit the same key or another key?

Share this post


Link to post
Share on other sites

Global $Paused
HotKeySet("{PAUSE}", "TogglePause")

Func TogglePause()
    $Paused = NOT $Paused
    While $Paused
        sleep(100)
        ToolTip('Script is "Paused"',0,0)
    WEnd
    ToolTip("")
EndFunc

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