Jump to content

Pausing Scripts


Recommended Posts

This is the code included in the help file plus the edit to remove unwanted functions

; Press Esc to terminate script, Pause/Break to "pause"

Global $Paused
HotKeySet("!a", "TogglePause")

;;;; Body of program would go here;;;;
While 1
    Sleep(100)
WEnd
;;;;;;;;

Func TogglePause()
    $Paused = NOT $Paused
    While $Paused
        sleep(100)
     WEnd
EndFunc

The TogglePause function is never being called when I hit the assigned hotkey. I really don't care what the hotkey is... but I didn't want Escape. I've tried:

HotKeySet("!a", "TogglePause")

HotKeySet("{TAB}", "TogglePause")

HotKeySet("{!a}", "TogglePause") <--- just in case !a needed the brackets (didn't think it did)

To verify that it enters the loop command, I have a Send(".") in the Pause loop and a Send("x") in the Body loop that I'll view via Notepad. I commented out the Tooltips because I didn't believe them to be necessary.

I am having this run behind an application that doesn't minimize (It won't return control through Alt-Tab). That is just for reference in case that is the problem.

I am understand that the HotKeySet should NOT pass the keypresses to the application unless I use the "capture" type functions. However, they still do pass.

Any ideas what is amiss? Thanks in advance for whatever help you can offer.

Link to comment
Share on other sites

I figured that since the keys were still being "echoed" on-screen, that they weren't being passed through.

Is there a known work around? If not, thanks for replying so quick :D

***edit: typo***

Edited by stfields
Link to comment
Share on other sites

Hi,

This works for me. Tried with the following code:

Global $Paused
HotKeySet("!a", "TogglePause")

;;;; Body of program would go here;;;;
While 1
   Sleep(1000)
   MsgBox(0,"Not Paused", "Not Paused")
WEnd
;;;;;;;;

Func TogglePause()
   $Paused = NOT $Paused
   While $Paused
       sleep(100)
    WEnd
EndFunc

Are you sure hotkey combination ALT + a is not reserved by some other application?

Tuape

Link to comment
Share on other sites

Hi,

This works for me. Tried with the following code:

Global $Paused
HotKeySet("!a", "TogglePause")

;;;; Body of program would go here;;;;
While 1
   Sleep(1000)
   MsgBox(0,"Not Paused", "Not Paused")
WEnd
;;;;;;;;

Func TogglePause()
   $Paused = NOT $Paused
   While $Paused
       sleep(100)
    WEnd
EndFunc

Are you sure hotkey combination ALT + a is not reserved by some other application?

Tuape

I can confirm: this works here too.
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...