Aquí la clase
Code: Select all
class func2timer{
;OBJETO PARA CREAR UN BUCLE CON UN TIMER
;SE TIENE QUE PASAR LA FUNCION DEL BUCLE, SE PUEDE INICIAR O TERMINAR LA FUNCION CON ALGO
;SE PUEDE MODIFICAR EL DELAY DEL TIMER
__New(loopFunction,initFunction:="",endFunction:="",delay:=0){
if !IsFunc(loopFunction)
return ErrorLevel
this.function:=loopFunction
this.initFunction:=initFunction
this.endFunction:=endFunction
this.delay:=delay
this.timer:=ObjBindMethod(this, "tick")
}
init(){
if IsFunc(this.initFunction)
this.initFunction(this)
timer:=this.timer
SetTimer, % timer, % this.delay
}
tick(){
if IsFunc(this.function)
this.function(this)
}
fin(){
if IsFunc(this.endFunction)
this.endFunction(this)
timer:=this.timer
SetTimer, % timer,Off
}
}
EJEMPLO