#Persistent

Auto Hotkey

#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 and all other threads have exited. This is usually unnecessary because the script automatically becomes persistent when the program detects that it has some way of launching new threads, such as a hotkey, timer or GUI.

Some cases where this directive might be needed (if there are no running threads or hotkeys, timers, etc.) include:

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.

Related

Exit, ExitApp

Example

; This script will not exit automatically, even though it has nothing to do.
; However, you can use its tray icon to open the script in an editor, or to
; launch Window Spy or the Help file.
#Persistent