Following on from my recent post, it would be great if a directive like #ExitAppOnUnhandledException was added to AHK. The benefit of such a directive is to simplify closing the script on an unhandled exception when the script would traditionally stay open due to persistence. While there is code to enable this functionality, it requires advanced AHK knowledge so isn't easy to understand.
IMO I would like to define an unhandled Exception function that can process the Exception in my AHK script, but that seems fairly complicated. Not all information is included in the unhandled exception error message (such as the function name), so the workaround linked above doesn't give us all the important information about an exception.
My attempts at adding this functionality are here and here. Unfortunately I can't use this functionality due to a strict antivirus policy, all scripts compiled with my custom AHK version get flagged. Regular AHK versions work fine though.
I will see if I can make a pull request.
Add directive #ExitAppOnUnhandledException Topic is solved
Re: Add directive #ExitAppOnUnhandledException Topic is solved
I think OnError superseded this.
Code: Select all
; AutoHotkey v1.1.29+
OnError("UnhandledException")
UnhandledException() {
ExitApp
}
MsgBox 1
%blank% := 1
MsgBox 2
Code: Select all
; AutoHotkey v2.0-a097+
OnError (*) => ExitApp()
MsgBox 1
x := 0/0
MsgBox 2
Who is online
Users browsing this forum: william_ahk and 28 guests