Jump to content

Search the Community

Showing results for tags 'onautoitexitregister'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


  • General
    • Announcements and Site News
    • Administration
  • AutoIt v3
    • AutoIt Help and Support
    • AutoIt Technical Discussion
    • AutoIt Example Scripts
  • Scripting and Development
    • Developer General Discussion
    • Language Specific Discussion
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office


  • AutoIt Team
    • Beta
    • MVP
  • AutoIt
    • Automation
    • Databases and web connections
    • Data compression
    • Encryption and hash
    • Games
    • GUI Additions
    • Hardware
    • Information gathering
    • Internet protocol suite
    • Maths
    • Media
    • PDF
    • Security
    • Social Media and other Website API
    • Windows
  • Scripting and Development
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office

Find results in...

Find results that contain...

Date Created

  • Start


Last Updated

  • Start


Filter by number of...


  • Start



Member Title




Found 6 results

  1. We get new features but the awareness does not propagate and become common knowledge fast enough so, here is an example of use: Opt("SetExitCode", 1) OnAutoItExitRegister("__OnAutoItExit") Example() Func Example() Local $n, $a[6] = [5, 5, 4, 3, 2, 1] For $n = 1 To 100 ToolTip('..crashing in ' & $a[$n], 50, 50, "CrashTest") ConsoleWrite('..crashing in ' & $a[$n] & @CRLF) Sleep(500) Next EndFunc ;==>Example Func __OnAutoItExit() Local $sExitMethod Switch @exitMethod Case 0 $sExitMethod = "closed by natural closing." Case 1 $sExitMethod = "closed by Exit function." Case 2 $sExitMethod = "closed by clicking on exit of the systray." Case 3 $sExitMethod = "closed by user logoff." Case 4 $sExitMethod = "closed by Windows shutdown." Case Else $sExitMethod = "closed by no clue." EndSwitch ;~ If @exitCode Then MsgBox(262144, @ScriptName, "I could do something with the error from here", 2) MsgBox(262144, @ScriptName, "Oh !, wait, we now can =)" & @CR & _ @CR & "The error was: " & Hex(@exitCode) & _ @CR & "Meaning: """ & FatalErrormessageFromExitCode(@exitCode) & """" & _ @CR & "and the ExitMethod was """ & $sExitMethod & """" & _ @CR & @CR & " =)", 60) EndFunc ;==>__OnAutoItExit Func FatalErrormessageFromExitCode($iExitCode) ; from the help file Local $sExitCode = 'uncatalogued event' Switch $iExitCode Case 0x7FFFF068 $sExitCode = '"EndWith" missing "With". ' Case 0x7FFFF069 $sExitCode = 'Badly formatted "Func" statement. ' Case 0x7FFFF06A $sExitCode = '"With" missing "EndWith". ' Case 0x7FFFF06B $sExitCode = 'Missing right bracket '') '' in expression. ' Case 0x7FFFF06C $sExitCode = 'Missing operator in expression. ' Case 0x7FFFF06D $sExitCode = 'Unbalanced brackets in expression. ' Case 0x7FFFF06E $sExitCode = 'Error in expression. ' Case 0x7FFFF06F $sExitCode = 'Error parsing function call. ' Case 0x7FFFF070 $sExitCode = 'Incorrect number of parameters in function call. ' Case 0x7FFFF071 $sExitCode = '"ReDim" used without an array variable. ' Case 0x7FFFF072 $sExitCode = 'Illegal text at the end of statement (one statement per line). ' Case 0x7FFFF073 $sExitCode = '"If" statement has no matching "EndIf" statement. ' Case 0x7FFFF074 $sExitCode = '"Else" statement with no matching "If" statement. ' Case 0x7FFFF075 $sExitCode = '"EndIf" statement with no matching "If" statement. ' Case 0x7FFFF076 $sExitCode = 'Too many "Else" statements for matching "If" statement. ' Case 0x7FFFF077 $sExitCode = '"While" statement has no matching "WEnd" statement. ' Case 0x7FFFF078 $sExitCode = '"WEnd" statement with no matching "While" statement. ' Case 0x7FFFF079 $sExitCode = 'Variable used without being declared. ' Case 0x7FFFF07A $sExitCode = 'Array variable has incorrect number of subscripts or subscript dimension range exceeded. ' Case 0x7FFFF07B $sExitCode = 'Variable subscript badly formatted. ' Case 0x7FFFF07C $sExitCode = 'Subscript used on non-accessible variable. ' Case 0x7FFFF07D $sExitCode = 'Too many subscripts used for an array. ' Case 0x7FFFF07E $sExitCode = 'Missing subscript dimensions in "Dim" statement. ' Case 0x7FFFF07F $sExitCode = 'No variable given for "Dim", "Local", "Global", "Static" or "Const" statement. ' Case 0x7FFFF080 $sExitCode = 'Expected a "=" operator in assignment statement. ' Case 0x7FFFF081 $sExitCode = 'Invalid keyword at the start of this line. ' Case 0x7FFFF082 $sExitCode = 'Array maximum size exceeded. ' Case 0x7FFFF083 $sExitCode = '"Func" statement has no matching "EndFunc". ' Case 0x7FFFF084 $sExitCode = 'Duplicate function name. ' Case 0x7FFFF085 $sExitCode = 'Unknown function name. ' Case 0x7FFFF086 $sExitCode = 'Unknown macro. ' Case 0x7FFFF088 $sExitCode = 'Unable to get a list of running processes. ' Case 0x7FFFF08A $sExitCode = 'Invalid element in a DllStruct. ' Case 0x7FFFF08B $sExitCode = 'Unknown option or bad parameter specified. ' Case 0x7FFFF08C $sExitCode = 'Unable to load the internet libraries. ' Case 0x7FFFF08D $sExitCode = '"Struct" statement has no matching "EndStruct". ' Case 0x7FFFF08E $sExitCode = 'Unable to open file, the maximum number of open files has been exceeded. ' Case 0x7FFFF08F $sExitCode = '"ContinueLoop" statement with no matching "While", "Do" or "For" statement. ' Case 0x7FFFF090 $sExitCode = 'Invalid file filter given. ' Case 0x7FFFF091 $sExitCode = 'Expected a variable in user function call. ' Case 0x7FFFF092 $sExitCode = '"Do" statement has no matching "Until" statement. ' Case 0x7FFFF093 $sExitCode = '"Until" statement with no matching "Do" statement. ' Case 0x7FFFF094 $sExitCode = '"For" statement is badly formatted. ' Case 0x7FFFF095 $sExitCode = '"Next" statement with no matching "For" statement. ' Case 0x7FFFF096 $sExitCode = '"ExitLoop/ContinueLoop" statements only valid from inside a For/Do/While loop. ' Case 0x7FFFF097 $sExitCode = '"For" statement has no matching "Next" statement. ' Case 0x7FFFF098 $sExitCode = '"Case" statement with no matching "Select" Or "Switch" statement. ' Case 0x7FFFF099 $sExitCode = '"EndSelect" statement with no matching "Select" statement. ' Case 0x7FFFF09A $sExitCode = 'Recursion level has been exceeded - AutoIt will quit to prevent stack overflow. ' Case 0x7FFFF09B $sExitCode = 'Cannot make existing variables static. ' Case 0x7FFFF09C $sExitCode = 'Cannot make static variables into regular variables. ' Case 0x7FFFF09D $sExitCode = 'Badly formated Enum statement ' Case 0x7FFFF09F $sExitCode = 'This keyword cannot be used after a "Then" keyword. ' Case 0x7FFFF0A0 $sExitCode = '"Select" statement is missing "EndSelect" or "Case" statement. ' Case 0x7FFFF0A1 $sExitCode = '"If" statements must have a "Then" keyword. ' Case 0x7FFFF0A2 $sExitCode = 'Badly formated Struct statement. ' Case 0x7FFFF0A3 $sExitCode = 'Cannot assign values to constants. ' Case 0x7FFFF0A4 $sExitCode = 'Cannot make existing variables into constants. ' Case 0x7FFFF0A5 $sExitCode = 'Only Object-type variables allowed in a "With" statement. ' Case 0x7FFFF0A6 $sExitCode = '"long_ptr", "int_ptr" and "short_ptr" DllCall() types have been deprecated. Use "long*", "int*" and "short*" instead. ' Case 0x7FFFF0A7 $sExitCode = 'Object referenced outside a "With" statement. ' Case 0x7FFFF0A8 $sExitCode = 'Nested "With" statements are not allowed. ' Case 0x7FFFF0A9 $sExitCode = 'Variable must be of type "Object". ' Case 0x7FFFF0AA $sExitCode = 'The requested action with this object has failed. ' Case 0x7FFFF0AB $sExitCode = 'Variable appears more than once in function declaration. ' Case 0x7FFFF0AC $sExitCode = 'ReDim array can not be initialized in this manner. ' Case 0x7FFFF0AD $sExitCode = 'An array variable can not be used in this manner. ' Case 0x7FFFF0AE $sExitCode = 'Can not redeclare a constant. ' Case 0x7FFFF0AF $sExitCode = 'Can not redeclare a parameter inside a user function. ' Case 0x7FFFF0B0 $sExitCode = 'Can pass constants by reference only to parameters with "Const" keyword. ' Case 0x7FFFF0B1 $sExitCode = 'Can not initialize a variable with itself. ' Case 0x7FFFF0B2 $sExitCode = 'Incorrect way to use this parameter. ' Case 0x7FFFF0B3 $sExitCode = '"EndSwitch" statement with no matching "Switch" statement. ' Case 0x7FFFF0B4 $sExitCode = '"Switch" statement is missing "EndSwitch" or "Case" statement. ' Case 0x7FFFF0B5 $sExitCode = '"ContinueCase" statement with no matching "Select" Or "Switch" statement. ' Case 0x7FFFF0B6 $sExitCode = 'Assert Failed! ' Case 0x7FFFF0B8 $sExitCode = 'Obsolete function/parameter. ' Case 0x7FFFF0B9 $sExitCode = 'Invalid Exitcode (reserved for AutoIt internal use). ' Case 0x7FFFF0BA $sExitCode = 'Variable cannot be accessed in this manner. ' Case 0x7FFFF0BB $sExitCode = 'Func reassign not allowed. ' Case 0x7FFFF0BC $sExitCode = 'Func reassign on global level not allowed. ' EndSwitch Return SetError(0, $iExitCode, $sExitCode) EndFunc ;==>FatalErrormessageFromExitCode Edit: There are wrapper functions in v3.3.16.1 but did not know, otherwise I'd have saved me the coding. These func. are _FormatAutoItExitCode() and _FormatAutoItExitMethod() . I created the post after reviewing my tracs and decided to bla, bla, bla ... , and posted
  2. Hi all, I'm working on a relatively complex automation program and I need it to call a specific function when it is closed by a user. Ive resorted to "OnAutoItExitRegister" as i believe that's the only option available. This command works perfectly fine in a small scale test application I wrote, but once implemented in the final program that's much larger and divided over many files in many directories it no longer works. I don't get any error messages. My question is has anyone encountered an issue where implementation of this command in a large scale program gave them trouble? Does it matter where "OnAutoItExitRegister" is called and where the function is located? Currently they are both places in the main file that runs the whole program but it still doesn't work. Any help is appreciated
  3. I have created an exit function and registered using OnAutoItExitRegister.But it is not running when I close the app from taskbar or even with normal exit during end. Below is the part of code and the included files. #include <MsgBoxConstants.au3> #include <FileConstants.au3> #include <WinAPIFiles.au3> #include <Date.au3> #include <file.au3> #include <Array.au3> #include <String.au3> OnAutoItExitRegister("Exit_Program") Func Exit_Program() LoggingMainScr("Entered Exit_Program") Local $exitmethod = ["Natural closing", "close by Exit function", "close by clicking on exit of the systray","close by user logoff","close by Windows shutdown"] ExitProgram("Exit with exit code: "& @exitCode & " And because of: " & $exitmethod[@exitmethod],@exitmethod) EndFunc Func ExitProgram($sReason="Exit by user",$sCode=0) LoggingMainScr($sReason) if $sCode <> 0 then LoggingMainScr("stopped before completion") FileDelete(@ScriptDir&"\Machines*.txt") FileDelete(@ScriptDir&"\PsExec.exe") FileDelete(@ScriptDir&"\HyperVMachines.ps1") FileDelete(@ScriptDir&"\VMwareMachines.ps1") EndFunc Func LoggingMainScr($sMessage) LoggingDefault($sMessage,@ScriptDir&"\MainScr_Logging.log") EndFunc Func LoggingDefault($sMessage,$sLogFile=@ScriptDir&"\Logging.log") If $sMessage = "" Then FileWriteLine($sLogFile, "") Else FileWrite($sLogFile,_NowCalc() & " :: " & $sMessage&@CRLF) EndIf EndFunc Any suggestion.
  4. Tell me why when I shut down Windows, OnAutoItExitRegister function is activated twice? This is an example of the reference #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
  5. When I try to compile the following code: #NoTrayIcon #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Run_Au3Stripper=y #Au3Stripper_Parameters=/rm #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** OnAutoItExitRegister("_exit") Func _exit() ConsoleWrite("kek") EndFunc The stripped version has the _exit() function stripped. The stripped code: #NoTrayIcon OnAutoItExitRegister("_exit") When I check the Au3Stripper log it shows: 0.00 AutoIt3 Source Au3Stripper v16.612.1119.0 Copyright © Jos van der Zande June 12,2016 0.00 CommandLine Params$: 0.00 ============================== Reading Source For Directive ====================================================== 0.00 Ignore Function: onautoitstart 0.00 Ignore Function: onautoitexit 0.00 Directive Params$:/rm 0.00 lCMD$:/rm 0.00 /RenameMinimum Is this a bug? I know I can fix this with '#Au3Stripper_Ignore_Funcs=_exit'. This error also occurs with HotKeySet. The function that HotKeySet points to is stripped.
  6. Any way i can detect if my exe is 'end tasked' ? I would like to display a msgbox or write a log file just before the task is closed.
  • Create New...