Suspend

Disables or enables all or selected hotkeys and hotstrings.

Suspend NewState

Parameters

NewState

Type: Integer

If omitted, it defaults to -1. Otherwise, specify one of the following values:

1 or True: Suspends all hotkeys and hotstrings except those explained the Remarks section.

0 or False: Re-enables the hotkeys and hotstrings that were disable above.

-1: Changes to the opposite of its previous state (On or Off).

Remarks

By default, the script can also be suspended via its tray icon or main window.

A hotkey/hotstring can be made exempt from suspension by preceding it with the #SuspendExempt directive. An exempt hotkey/hotstring will remain enabled even while suspension is ON. This allows suspension to be turned off via a hotkey, which would otherwise be impossible since the hotkey would be suspended.

The keyboard and/or mouse hooks will be installed or removed if justified by the changes made by this function.

To disable selected hotkeys/hotstrings automatically based on any condition, such as the type of window that is active, use #HotIf.

Suspending a script's hotkeys does not stop the script's already-running threads (if any); use Pause to do that.

When a script's hotkeys are suspended, its tray icon changes to a green icon with a transparent H (or to a green icon with a transparent Pause symbol if the script is also paused). This icon change can be avoided by freezing the icon, which is achieved by using TraySetIcon(,, true).

The built-in variable A_IsSuspended contains 1 if the script is suspended and 0 otherwise.

#SuspendExempt, Hotkeys, Hotstrings, #HotIf, Pause, ExitApp

Examples

Press a hotkey once to suspend all hotkeys and hotstrings. Press it again to unsuspend.

#SuspendExempt
^!s::Suspend  ; Ctrl+Alt+S
#SuspendExempt False

Sends a Suspend command to another script.

DetectHiddenWindows True
WM_COMMAND := 0x0111
ID_FILE_SUSPEND := 65404
PostMessage WM_COMMAND, ID_FILE_SUSPEND,,, "C:\YourScript.ahk ahk_class AutoHotkey"