Hi
KuroiLight,
Here's a solution. I don't know if it is the only one and, in particular, the less hard-coded and efficient one (btw I already gave you an example on how hotkeys makes class objects un-freeable in a previous post).
Code: Select all
t := (t:=new test()).free()
return
Class test {
__New() {
MsgBox,,, % A_ThisFunc, 1
f_func1 := this.f_func1 := ObjBindMethod(this, "func1")
Hotkey, CapsLock, %f_func1%, On
}
free() {
randomFunc := Func("WinActive").bind("A")
Hotkey, CapsLock, % randomFunc, On
this.f_func1 := ""
return ""
}
func1() {
ToolTip, % "hello world"
}
__Delete() {
MsgBox,,, % A_ThisFunc, 1
}
}
If you're looking for a general solution you can take a look at
this [francophone forum] Hotkey OOP wrapper for the hotkey command I made a short time ago (you'll also find there a link to
RUNIE's one from which I build it) and which implement a
delete method.