OnExit Func Inside a Class Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
User avatar
Delta Pythagorean
Posts: 627
Joined: 13 Feb 2017, 13:44
Location: Somewhere in the US
Contact:

OnExit Func Inside a Class

02 Feb 2019, 17:46

With the "new" OnExit func, I want to be able to exit the script and have the OnExit function to be a function that's inside a class (Without using __Delete).

For example:

Code: Select all

Class StartupClass {
	__New() {
		OnExit() ; What goes in here?
	}
}

Class ExitClass {
	OnExitFunction() {
		MsgBox, Closing down!
	}
}

[AHK]......: v2.0.12 | 64-bit
[OS].......: Windows 11 | 23H2 (OS Build: 22621.3296)
[GITHUB]...: github.com/DelPyth
[PAYPAL]...: paypal.me/DelPyth
[DISCORD]..: tophatcat

User avatar
Delta Pythagorean
Posts: 627
Joined: 13 Feb 2017, 13:44
Location: Somewhere in the US
Contact:

Re: OnExit Func Inside a Class  Topic is solved

02 Feb 2019, 17:51

Nevermind, I need to read the Docs more often.
AHK Docs wrote:

Code: Select all

; Register an object to be called on exit:
OnExit(ObjBindMethod(MyObject, "Exiting"))

class MyObject
{
	Exiting()
	{
		MsgBox, MyObject is cleaning up prior to exiting...
		/*
		this.SayGoodbye()
		this.CloseNetworkConnections()
		*/
	}
}

[AHK]......: v2.0.12 | 64-bit
[OS].......: Windows 11 | 23H2 (OS Build: 22621.3296)
[GITHUB]...: github.com/DelPyth
[PAYPAL]...: paypal.me/DelPyth
[DISCORD]..: tophatcat


Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: jollyjoe and 352 guests