Jump to content

OnAutoItExitRegister() in version 3.2.12.1 or earlier


Go to solution Solved by Jos,

Recommended Posts

I need to compile a script that works in windows 98 with a function similar to OnAutoItExitRegister() to execute commands when windows is closed but I couldn't find the name of the function used in 2008, does anyone know what it was?

Link to comment
Share on other sites

@Belini AutoIt 3.2.10.0, help file dated Dec 25, 2007

Func OnAutoItExit ()...EndFunc 
Defines a user-defined function that will be called when the script exit.

Func OnAutoItExit ( )
    ...
EndFunc

Parameters
None.

Remarks
Inside the function, @ExitCode can be used to retrieve the code set by the exit statement.
The mode of exit can be retrieved with @ExitMethod.

0 Natural closing. 
1 close by Exit function. 
2 close by clicking on exit of the systray. 
3 close by user logoff. 
4 close by Windows shutdown. 

Related
Func OnAutoItStart (), OnExitFunc (Option) 

Example
Opt("OnExitFunc", "endscript")
MsgBox(0,"","first statement")

Func endscript()
    MsgBox(0,"","after last statement " & @EXITMETHOD)
EndFunc

Edit: same syntax in Autoit 3.2.12.0 (May 16, 2008)
Edited by pixelsearch
Link to comment
Share on other sites

@Andreik yes i want to run a function when the operating system is about to shut down.

@pixelsearch I found version 3.2.10.0 and version 3.2.12.0 to download, but I couldn't find Scite to download and OnAutoItExit() still doesn't work, does anyone know where I can download Scite from these versions?

ERROR: OnAutoItExit(): undefined function.
OnAutoItExit("Encerrar")

 

 

Edited by Belini
Link to comment
Share on other sites

Nicely written Jos, with tact :)
Bing translates it like this :

@Andreik : Yes, I want to perform a function when the operating system is about to shut down. 

@pixelsearch I found version 3.2.10.0 and version 3.2.12.0 to download, but I couldn't find Scite to download and OnAutoItExit() still doesn't work, does anyone know where I can download Scite from these versions?

Link to comment
Share on other sites

@Jos and @pixelsearch I posted in English but my page translator switched to Portuguese when I posted and I didn't notice it.

I got the scite from versions 3.2.10.0 and version 3.2.12.0 but the OnAutoItExit() function is still not recognized.

ERROR: OnAutoItExit(): undefined function.
OnAutoItExit("Encerrar")

 

Link to comment
Share on other sites

  • Developers

SciTE plays no role here, so what exactly is the error you get ? Please simple share the full SciTE output pane  information when you run the script!

Edited by Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

  • Developers

That isn't the SciTE output pane output but rather the au3check output. Likely you do not have the proper definition for au3check , so hence you get this error returned by it. Just disable the au3check and only run the script with autoit3.

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

The same error continues

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Run_AU3Check=n
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****

OnAutoItExit("Encerrar")

While 1
    Sleep(1000)
WEnd

Func Encerrar()
    While 1
        ProcessClose("advmenu.exe")
        Send("{enter down}")
        Sleep(50)
        Send("{enter up}")
    WEnd
EndFunc   ;==>Encerrar

 

>"C:\Program Files (x86)\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.exe" /run /prod /ErrorStdOut /in "D:\Encerrar.au3" /autoit3dir "C:\Arquivos de programas\AutoIt3" /UserParams    
+>15:20:38 Starting AutoIt3Wrapper v.1.10.1.14    Environment(Language:0416  Keyboard:00000416  OS:WIN_2008/Service Pack 1  CPU:X64  ANSI)
>Running:(3.2.10.0):C:\Program Files (x86)\AutoIt3\autoit3.exe "D:\Encerrar.au3"    
D:\Encerrar.au3 (5) : ==> Unknown function name.: 
OnAutoItExit("Encerrar") 
^ ERROR
->15:20:38 AutoIT3.exe ended.rc:1
+>15:20:39 AutoIt3Wrapper Finished
>Exit code: 1    Time: 1.200

 

Version:  3.2.10.0

Edited by Belini
Link to comment
Share on other sites

  • Developers
  • Solution

Open the Helpfile that comes with the version and you will find that you have the syntax all wrong.

It should be:

Opt("OnExitFunc", "Encerrar")

 

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...