Pauses the script's current thread or sets the pause state of the underlying thread.
Pause UnderlyingThreadState
Type: Integer
If omitted, the current thread is paused. Otherwise, specify one of the following values:
1 or True: Marks the underlying thread as paused. The current thread is not paused and continues running. When the current thread finishes, the underlying thread enters a paused state as soon as it resumes, even inside a function it was interrupted in, such as WinWait. In AutoHotkey v2.1, the underlying thread first finishes that function. If there is no thread underneath the current thread, the script itself is paused, which prevents timers from running. In the auto-execute thread, this has no effect.
0 or False: Unpauses the underlying thread.
-1: Toggles the pause state of the underlying thread.
By default, the script can also be paused via its tray icon or main window. The Pause Script item toggles the thread that was running when it was chosen, or the script itself if none was. It runs as a new thread, so it cannot unpause a Critical thread; in AutoHotkey v2.1, it can.
Unlike Suspend -- which disables hotkeys and hotstrings -- turning on pause will freeze the thread (the current thread if UnderlyingThreadState was omitted, otherwise the underlying thread). As a side-effect, any interrupted threads underneath it will lie dormant until the current thread is unpaused and finishes.
Whenever any thread or the script itself is paused, timers will not run. A thread paused on a RealThread holds off only the timers of that real thread. By contrast, explicitly launched threads such as hotkeys, menu items and work posted from another real thread can still be launched and can unpause the thread; but when their threads finish, the underlying thread will still be paused. In other words, each thread can be paused independently of the others.
The tray icon changes to a pause icon whenever the script's current thread is in a paused state, and keeps it if the script is also suspended. In AutoHotkey v2.1, a paused and suspended script has an icon of its own. This icon change can be avoided by freezing the icon, which is achieved by using TraySetIcon(,, true).
To disable timers without pausing a thread, use Thread NoTimers.
A script is always halted (though not officially paused) while it is displaying any kind of menu (tray menu, menu bar, GUI context menu, etc.)
The built-in variable A_IsPaused contains 1 if the thread immediately underneath the current thread is paused and 0 otherwise. Writing to it, and to Thread.Paused, sets the same flag Pause 1 sets.
Suspend, Menu object, ExitApp, Threads, SetTimer