OnExit Func Inside a Class Topic is solved

Get help with using AutoHotkey and its commands and hotkeys
User avatar
Delta Pythagorean
Posts: 474
Joined: 13 Feb 2017, 13:44
GitHub: DelPyth
Location: Somewhere in the US

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!
	}
}
User avatar
Delta Pythagorean
Posts: 474
Joined: 13 Feb 2017, 13:44
GitHub: DelPyth
Location: Somewhere in the US

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()
		*/
	}
}

Return to “Ask For Help”

Who is online

Users browsing this forum: AHKStudent, Bing [Bot], toralf and 246 guests