Pause

Pauses the script's current thread.

Pause [, On|Off|Toggle, OperateOnUnderlyingThread?]

 

Parameters

On|Off|Toggle

If blank or omitted, it defaults to Toggle. Otherwise, specify one of the following words:

Toggle: Pauses the current thread unless the thread beneath it is paused, in which case the underlying thread is unpaused.

On: Pauses the current thread.

Off: If the thread beneath the current thread is paused, it will be in an unpaused state when resumed. Otherwise, the command has no effect.

OperateOnUnderlyingThread?
[v1.0.37.06+]

This parameter is ignored for "Pause Off". For the others, it is ignored unless Pause is being turned on (including via Toggle).

Specify one of the following numbers:

0 or omitted: The command pauses the current thread; that is, the one now running the Pause command.

1: The command marks the thread beneath the current thread as paused so that when it resumes, it will finish the command it was running (if any) and then enter a paused state. If there is no thread beneath the current thread, the script itself is paused, which prevents timers from running (this effect is the same as having used the menu item "Pause Script" while the script has no threads).

 

Remarks

Unlike Suspend -- which disables hotkeys and hotstrings-- pause will freeze the thread. As a side-effect, any interrupted threads beneath it will lie dormant.

Whenever any thread is paused, timers will not run. By contrast, explicitly launched threads such as hotkeys and menu items can still be launched; but when their threads finish, the underlying interrupted thread will still be paused. In other words, each thread can be paused independently of the others.

The color of the tray icon changes from green to red whenever the script's current thread is in a paused state. This can be avoided by freezing the icon, which is achieved by specifying 1 for the last parameter of the Menu command. For example:
Menu, Tray, Icon, C:\My Icon.ico, , 1

To disable timers without pausing the script, use "Thread, NoTimers".

The Pause command is similar in function to the built-in menu item "Pause Script".

A script is always halted (though not officially paused) while its tray menu or main window's menu is displayed.

 

Related

Suspend, Menu, ExitApp, Threads, SetTimer

 

Examples

Pause::Pause  ; Assign the toggle-pause function to the "pause" key...
#p::Pause  ; ... or assign it to Win+p or some other hotkey.