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_BYSHUTDOWN (4) close by Windows shutdown.

@exitMethod can be formated with _FormatAutoItExitMethod().

If Opt("SetExitCode", 1) is used the @exitCode is set according to the Fatal error message - see AutoIt3 Fatal Error Exit codes.

If "AutoItExitCodes.au3" is included, _FormatAutoItExitCode() can be called to have a string representation of the @ExitCode.

Constants are defined in "AutoItConstants.au3".

Related

Exit, OnAutoItExitUnRegister, OnAutoItStartRegister, SetExitCode (Option), _FormatAutoItExitCode, _FormatAutoItExitMethod

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