The timer is working if I point to the Instantiation of the Class. Not sure if it's the right term.
Code: Select all
SetTimer () => Monitor.WinStatusFinder(hWnd), -125
Code: Select all
SetTimer () => this.WinStatusFinder(hWnd), -125
Code: Select all
#Requires AutoHotkey v2.0
#SingleInstance Force
Persistent
Monitor := Monitoring()
Monitor.Add({Window:[{WinTitle:"WordPad"}]})
Class Monitoring {
Add(oEvent)
{
if oEvent.HasOwnProp("Window")
SetTimer () => this.WindowMonitoring_Start(), -1
/*
Negative timer to wait until all windows are added before starting monitoring.
The auto-execute thread has a priority of 0, so by default any timer with a negative priority will not fire
until after the auto-execute section finishes. - lexikos
https://www.autohotkey.com/boards/viewtopic.php?style=17&p=460135
*/
}
WindowMonitoring_Start()
{
this.HookProcAdr := CallbackCreate(this.CaptureWinEvent, "F")
this.hWinEventHook := this.SetWinEventHook(0x1, 0x17, 0, this.HookProcAdr, 0, 0, 0x1)
}
SetWinEventHook(eventMin, eventMax, hmodWinEventProc, lpfnWinEventProc, idProcess, idThread, dwFlags)
{
return DllCall("SetWinEventHook", "Uint", eventMin, "Uint", eventMax, "Uint", hmodWinEventProc, "Uint", lpfnWinEventProc, "Uint", idProcess, "Uint", idThread, "Uint", dwFlags)
}
CaptureWinEvent(Event, hWnd, idObject, idChild, dwEventThread, dwmsEventTime)
{
SetTimer () => Monitor.WinStatusFinder(hWnd), -125 ; <= This is working.
; SetTimer () => this.WinStatusFinder(hWnd), -125 ; <= Why I get an error with this ? Error: This value of type "Integer" has no method named "WinStatusFinder".
}
WinStatusFinder(hWnd)
{
; Debug(hWnd)
}
}