Suspend()

Auto Hotkey

Suspend

Disables or enables all or selected hotkeys and hotstrings.

Suspend Mode
Command  Example: Suspend "On"
Function Example: Suspend("On")

Parameters

Mode

On or 1 (true): Suspends all hotkeys and hotstrings except those explained the Remarks section.

Off or 0 (false): Re-enables the hotkeys and hotstrings that were disable above.

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

Permit: Does nothing except mark the current subroutine as being exempt from suspension.

Remarks

Any hotkey/hotstring subroutine whose very first line is Suspend (except Suspend On) will be exempt from suspension. In other words, the hotkey will remain enabled even while suspension is ON. This allows suspension to be turned off via such a hotkey.

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

To disable selected hotkeys or hotstrings automatically based on the type of window that is present, use #IfWinActive/Exist.

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 the letter S. This can be avoided by freezing the icon, which is done by specifying 1 for the last parameter of the Menu command. For example:

Menu, Tray, Icon, C:\My Icon.ico, , 1

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

Related

#IfWinActive/Exist, Pause, Menu, ExitApp

Example

^!s::Suspend  ; Assign the toggle-suspend function to a hotkey.
; Send a Suspend command to another script.
DetectHiddenWindows, On
WM_COMMAND := 0x111
ID_FILE_SUSPEND := 65404
PostMessage, %WM_COMMAND%, %ID_FILE_SUSPEND%,,, C:\YourScript.ahk ahk_class AutoHotkey