Function Reference


OnAutoItExitRegister

Registers a function to be called when AutoIt exits.

OnAutoItExitRegister ( "function" )

Parameters

function The name of the user function to call.

Return Value

Success: 1. @extended can be set if already registered.
Failure: 0.

Remarks

The exit code can be retrieved with @exitCode.
The mode of exit can be retrieved with @exitMethod.

$EXITCLOSE_NORMAL (0) Natural closing.
$EXITCLOSE_BYEXIT (1) close by Exit function.
$EXITCLOSE_BYCLICK (2) close by clicking on exit of the systray.
$EXITCLOSE_BYLOGOFF (3) close by user logoff.
$EXITCLOSE_BYSUTDOWN (4) close by Windows shutdown.

Constants are defined in "AutoItConstants.au3".

Related

Exit, OnAutoItExitUnRegister, OnAutoItStartRegister

Example

#include <MsgBoxConstants.au3>

OnAutoItExitRegister("MyTestFunc")
OnAutoItExitRegister("MyTestFunc2")

Sleep(1000)

Func MyTestFunc()
    MsgBox($MB_SYSTEMMODAL, "Exit Results 1", 'Exit Message from MyTestFunc()')
EndFunc   ;==>MyTestFunc

Func MyTestFunc2()
    MsgBox($MB_SYSTEMMODAL, "Exit Results 2", 'Exit Message from MyTestFunc()')
EndFunc   ;==>MyTestFunc2