Exit Autohotkey with ExitCode and ExitMessage

Get help with using AutoHotkey and its commands and hotkeys
mINXZKA
Posts: 6
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] [Download] GeSHi © Codebox Plus

echo Everything is OK
exit 0

vbs-example:

Code: [Select all] [Download] GeSHi © Codebox Plus

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


AutoHotkey?

Code: [Select all] [Download] GeSHi © Codebox Plus

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

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

Re: Exit Autohotkey with ExitCode and ExitMessage

20 Apr 2017, 07:45

Code: [Select all] [Download] (Untitled.ahk)GeSHi © Codebox Plus

OnExit("OnUnload")
return

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


Code: [Select all] [Expand] [Download] (Untitled.ahk)GeSHi © Codebox Plus

lexikos
Posts: 5264
Joined: 30 Sep 2013, 04:07
GitHub: Lexikos

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”

Who is online

Users browsing this forum: Google [Bot], kwanbis, Yahoo [Bot] and 23 guests