OBJETO TIMER INDIVIDUAL [PROPIEDADES Y FUNCIONES PERSONALIZADAS]
Posted: 27 Oct 2022, 19:54
Amigo les dejo esta clase que codifiqué con el fin de poder facilitar el uso de timers individuales que actuen a gusto utilizandolos con propiedades y funciones externas.
Aquí la clase
EJEMPLO
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