Persistent

Prevents the script from exiting automatically when its last thread completes, allowing it to stay running in an idle state.

PrevSetting := Persistent(Setting)

Parameters

Setting

Type: Boolean

If omitted, it defaults to true.

If true, the script will stay running after startup completes and all other threads have exited, even if none of the other conditions for keeping the script running are met.

If false, the default behaviour is restored.

Return Value

Type: Integer (boolean)

This function returns the previous setting; either 0 (false) for disabled or 1 (true) for enabled.

Remarks

By default, the script is not persistent. However, it becomes persistent automatically under certain conditions, specifically in common cases where the user would want it to keep running, such as when responding to hotkeys, executing timers, or displaying a GUI.

It is usually unnecessary to call this function, but there are some cases where it might be needed:

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

Exit, ExitApp

Examples

Prevent the script from exiting automatically.

; 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