Jump to content

Recommended Posts

I need a little help understanding what autoit is doing in my script when I have "pause" integrated. The g_bPaused was from the example I got. The g_aPaused was my attempt at creating a pause in my script by pressing the same hotkey again.  My question: will this essentially take up more RAM if I hit the same hotkey non-stop as oppose to pausing with the down arrow key?

Does hitting the down arrow key "pause" the loop function and executes the "togglepause" function? Is that literally happening?

Global $g_bPaused = False
Global $g_aPaused = False
HotKeySet("{UP}", "loop")
HotKeySet("{ESC}", "Terminate")
HotKeySet("{DOWN}", "TogglePause")

While 1

Func loop()
    $g_aPaused = Not $g_aPaused
    While $g_aPaused
        Local $hTimer = TimerInit() ; Begin the timer and store the handle in a variable.
        Local $fDiff = TimerDiff($hTimer)
        ConsoleWrite($fDiff & " miliseconds" & @LF)
    While Not $g_aPaused
        ToolTip('Script is "Paused"', 500, 500)
EndFunc   ;==>loop

Func TogglePause()
    $g_bPaused = Not $g_bPaused
    While $g_bPaused
        ToolTip('Script is "Paused"', 500, 500)
EndFunc   ;==>TogglePause

Func Terminate()
EndFunc   ;==>Terminate

Edited by element72
Link to post
Share on other sites

I don't understand your question. The TogglePause() example, in the help file, uses the same hotkey to both pause and resume your script. The first loop (outside the function) is interrupted by the hotkey press. Then TogglePause() interrupts itself the next time you press the hotkey (recursion). After interrupting itself, the script returns to the same point (inside the loop) in first instance of TogglePause(), checks the global flag and determines that it is no longer True (because it was switched back on the second call to the same function). When the flag is False, the loop ends, the function terminates and normal operations can resume.

Edited by czardas
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
  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...