I'm trying to make a class to monitor windows. I can't figure out how to identify separate timers to turn them individually on and off for the different windows, since they use the same binding calling the same method. It's hard to explain, the code is short and self-explanatory.
Code: Select all
MyEvents := WindowMonitoring()
MyEvents.Add({Window:"wordpad.exe", Function:"wordpad", Period:1000, WindowMonitoring:1})
MyEvents.Add({Window:"notepad.exe", Function:"notepad", Period:3000, WindowMonitoring:1})
class WindowMonitoring {
aEvents := []
Add(oEvent)
{
this.aEvents.push(oEvent)
eventIndex := this.aEvents.Length
function := this.CheckIfWinExist.bind(this, this.aEvents[eventIndex])
SetTimer function, oEvent.Period
}
CheckIfWinExist(oEvent)
{
; Debug(oEvent)
}
}
Code: Select all
MyEvents := WindowMonitoring()
MyEvents.Add({Window:"wordpad.exe", Function:"wordpad", Period:1000, WindowMonitoring:1})
MyEvents.Add({Window:"notepad.exe", Function:"notepad", Period:3000, WindowMonitoring:1})
class WindowMonitoring {
aEvents := []
Timer := WindowMonitoring.Timer()
Add(oEvent)
{
this.aEvents.push(oEvent)
eventIndex := this.aEvents.Length
thisEvent := this.aEvents[eventIndex]
thisEvent.EventIndex := eventIndex
this.Timer.AddTimer(thisEvent)
}
CheckIfWinExist(thisEvent)
{
; Debug(thisEvent)
}
class Timer {
AddTimer(thisEvent)
{
; Set different timers calling the method "CheckIfWinExist"
}
StartStopTimer(State, Timer)
{
}
}
}