@lexikos do you think calling
onmessage like this could impact somehow the performance of the script?
i mean, losing a message for example, or more use of CPU, idk ?
Code: Select all
OnMessage.Init()
Gui, Show, w600 h200
Return
F1:: ; Register a new message
OnMessage.New(0x0201, "WM_LBUTTONDOWN")
Return
F2:: ; Remove the message
OnMessage.Remove(0x0201, "WM_LBUTTONDOWN")
Return
WM_LBUTTONDOWN(wParam, lParam, Msg, Hwnd) {
FileAppend, WM_LBUTTONDOWN`n,*
}
Class OnMessage {
Init() {
this.New(0x0201, "OnMessage.WM_LBUTTONDOWN")
}
New(msg, function) {
If (!this.msg)
this.msg := {}
If (!this.msg[msg])
this.msg[msg] := {}
this.msg[msg][function] := Func(function).Bind(this)
For Index, Func in this.msg[msg]
OnMessage(msg, Func)
}
Remove(msg, function) {
func := this.msg[msg][function]
OnMessage(msg, func, 0)
}
WM_LBUTTONDOWN(wParam, lParam, Msg, Hwnd) {
FileAppend, ==> OnMessage.WM_LBUTTONDOWN`n,*
}
}