Jump to content
Sign in to follow this  

howto recognize a kill signal?

Recommended Posts


can autoit3 scripts recognize, when they get a signal to terminate, either by user action, another program or a windows shutdown?

I'd like to be able to do cleanup actions (write a final line to log file with reason, date+time of script termination) or to interrupt a triggered windows shutdown ("do you really want to shutdown your windows?")

Thanks for any suggestions,


Earth is flat, pigs can fly, and Nuclear Power is SAFE!

Share this post

Link to post
Share on other sites


OnAutoItExit ()

So long,


Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Share this post

Link to post
Share on other sites


thanks for your reply.

OnAutoItExit ()

I did read it but missed it's functionality. (thought it's about setting something like exitcode, my fault)

May I ask for the functionality?

0 Natural closing.

The script simply reached the last line of it's code?

1 close by Exit function.

there was a line reached doing an "EXIT" in the script

2 close by clicking on exit of the systray.

Only when clicking exit on the systray?

3 close by user logoff.

well, logoff

4 close by Windows shutdown.

Do you know what happens, when another script sends a winclose or a winkill, kill.exe is used or "end task" from task manager?

And how to write a autoit script some type of "hardened", so that it will *NOT* simply follow such requests, but pop up a dialog asking "do you really ...?" with an option to stop the "Sender" doing it's kill? e.g. some AV solutions can do so when an update is currently running to prevent a resulting status with a non operational AV scanner.

Regards, Rudi.

Earth is flat, pigs can fly, and Nuclear Power is SAFE!

Share this post

Link to post
Share on other sites

Just test it for yourself. Run this in SciTE:

While 1

Func OnAutoItExit()
    ConsoleWrite("Debug: OnAutoItExit: @ExitCode = " & @exitCode & "  @ExitMethod = " & @exitMethod & @LF)

Then kill it however you wish. If you remove the While loop, so there is no code but the one function, it exits with "@ExitCode = 0 @ExitMethod = 0".

Replace the While loop with just Exit, and you get "@ExitCode = 0 @ExitMethod = 1".

Running the While loop, and using Exit on the TrayIcon gets "@ExitCode = 0 @ExitMethod = 2".

Killing AutoIt3.exe from TaskManager results in a return of 2, but the function doesn't execute at all.

...etc., etc., test the method you are interested in.


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post

Link to post
Share on other sites

You may find this to be of some interest:


- The Kandie Man ;-)

"So man has sown the wind and reaped the world. Perhaps in the next few hours there will no remembrance of the past and no hope for the future that might have been." & _"All the works of man will be consumed in the great fire after which he was created." & _"And if there is a future for man, insensitive as he is, proud and defiant in his pursuit of power, let him resolve to live it lovingly, for he knows well how to do so." & _"Then he may say once more, 'Truly the light is sweet, and what a pleasant thing it is for the eyes to see the sun.'" - The Day the Earth Caught Fire

Share this post

Link to post
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
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...