</head> <body> <h1>Suspend</h1> <p>Disables or enables all or selected <a href="../Hotkeys.htm">hotkeys</a> and <a href="../Hotstrings.htm">hotstrings</a>.</p> <pre class="Syntax"><span class="func">Suspend</span> <span class="optional">, Mode</span></pre> <h2 id="Parameters">Parameters</h2> <dl> <dt>Mode</dt> <dd><p><strong>On</strong>: Suspends all <a href="../Hotkeys.htm">hotkeys</a> and <a href="../Hotstrings.htm">hotstrings</a> except those explained the Remarks section.</p> <p><strong>Off</strong>: Re-enables the hotkeys and hotstrings that were disable above.</p> <p><strong>Toggle</strong> (default): Changes to the opposite of its previous state (On or Off).</p> <p><strong>Permit</strong>: Does nothing except mark the current subroutine as being exempt from suspension.</p> <p><span class="ver">[v1.1.30+]:</span> The decimal values 1, 0 and -1 may be used in place of On, Off and Toggle, respectively.</p> </dd> </dl> <h2 id="Remarks">Remarks</h2> <p>By default, the script can also be suspended via its <a href="../Program.htm#tray-icon">tray icon</a> or <a href="../Program.htm#main-window">main window</a>.</p> <p>Any hotkey/hotstring subroutine whose very first line is Suspend (except <code>Suspend On</code>) 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.</p> <p>The <a href="_InstallKeybdHook.htm">keyboard</a> and/or <a href="_InstallMouseHook.htm">mouse</a> hooks will be installed or removed if justified by the changes made by this command.</p> <p>To disable selected hotkeys or hotstrings automatically based on the type of window that is present, use <a href="_IfWinActive.htm">#IfWinActive/Exist</a>.</p> <p>Suspending a script's hotkeys does not stop the script's already-running <a href="../misc/Threads.htm">threads</a> (if any); use <a href="Pause.htm">Pause</a> to do that.</p> <p>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:</p> <pre><a href="Menu.htm">Menu</a>, Tray, Icon, C:\My Icon.ico, , 1</pre> <p>The built-in variable <a href="../Variables.htm#IsSuspended">A_IsSuspended</a> contains 1 if the script is suspended and 0 otherwise.</p> <h2 id="Related">Related</h2> <p><a href="_IfWinActive.htm">#IfWinActive/Exist</a>, <a href="Pause.htm">Pause</a>, <a href="Menu.htm">Menu</a>, <a href="ExitApp.htm">ExitApp</a></p> <h2 id="Examples">Examples</h2> <div class="ex" id="ExHotkey"> <p><a class="ex_number" href="#ExHotkey"></a> Press a hotkey once to suspend all hotkeys and hotstrings. Press it again to unsuspend.</p> <pre>^!s::Suspend <em>; Ctrl+Alt+S</em></pre> </div> <div class="ex" id="PostMessage"> <p><a class="ex_number" href="#PostMessage"></a> Sends a Suspend command to another script.</p> <pre><a href="DetectHiddenWindows.htm">DetectHiddenWindows</a>, On WM_COMMAND := 0x0111 ID_FILE_SUSPEND := 65404 <a href="PostMessage.htm">PostMessage</a>, WM_COMMAND, ID_FILE_SUSPEND,,, C:\YourScript.ahk ahk_class AutoHotkey</pre> </div> </body> </html>