Exit Autohotkey with ExitCode and ExitMessage

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
mINXZKA
Posts: 13
Joined: 16 Mar 2016, 03:47

Exit Autohotkey with ExitCode and ExitMessage

20 Apr 2017, 04:25

With Nagios and NSClient++ I can set external scripts to watch whatever I want and capture the output (exitcode and exitmessage)

How can I send with AutoHotkey an ExitMessage similar to echo in cmd and vbscript?

cmd-example:

Code: Select all

echo Everything is OK
exit 0
vbs-example:

Code: Select all

Wscript.Echo "Everything is OK"
WScript.Quit(0)
AutoHotkey?

Code: Select all

;echo % "Everything is OK"   ; stderr  ?!
ExitApp, 0

; ExitApp, 0, % "Everything is OK"
User avatar
TheDewd
Posts: 1513
Joined: 19 Dec 2013, 11:16
Location: USA

Re: Exit Autohotkey with ExitCode and ExitMessage

20 Apr 2017, 07:45

Code: Select all

OnExit("OnUnload")
return

OnUnload(ExitReason, ExitCode) {
    MsgBox, % ExitReason ", " ExitCode
}

Code: Select all

#SingleInstance, Force

OnExit("OnUnload")

Gui, Margin, 10, 10
Gui, Add, Button, w200 h40 gClickLabel1, Exit
Gui, Add, Button, w200 h40 gClickLabel2, Reload
Gui, Show, AutoSize, Example
return

ClickLabel1:
    ExitApp
return

ClickLabel2:
    Reload
return

GuiEscape:
GuiClose:
    ExitApp
return

OnUnload(ExitReason, ExitCode) {
    MsgBox, % ExitReason ", " ExitCode
}
lexikos
Posts: 9592
Joined: 30 Sep 2013, 04:07
Contact:

Re: Exit Autohotkey with ExitCode and ExitMessage

20 Apr 2017, 22:48

Those "exit messages" are just ordinary messages which happen to be printed prior to exiting.

Echo prints to stdout. You can do the same thing with FileAppend or FileOpen and the filename * (just an asterisk).

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: just me and 76 guests