#Persistent - Syntax & Usage | AutoHotkey

AutoHotkey

#Persistent

Keeps a script permanently running (that is, until the user closes it or ExitApp is encountered).

#Persistent

If this directive is present anywhere in the script, that script will stay running after the auto-execute section (top part of the script) completes. This is useful in cases where a script contains timers and/or custom menu items but not hotkeys, hotstrings, or any use of OnMessage() or Gui.

If this directive is added to an existing script, you might want to change some or all occurrences of Exit to be ExitApp. This is because Exit will not terminate a persistent script; it terminates only the current thread.

[v1.0.16+]: This directive also makes a script single-instance. To override this or change the way single-instance behaves, see #SingleInstance.

Related

#SingleInstance, SetTimer, Menu, Exit, ExitApp

Example

#Persistent