Sign in to follow this  
Followers 0
Dinosaurr

Resetting a timer.

2 posts in this topic

$AutoHeal = 1
        $HealPotTimer = TimerInit()
    While 1
         If $AutoHeal = 1 And TimerDiff($HealPotTimer) >= 5000
               Heal()
           $HealPotTimer = TimerInit()
         EndIF
        WEnd
        Func Heal()
             WinActivate("Untitled - Notepad")
             Send("z")
        EndFunc

Im not looking for you to critique the code, im just looking to see why its not working. This isn't even the code im using so im not even sure if it works. Im just trying to give an example of what im trying to do.

Now on to the problem. It will only send the z key once after the timer has went off.

How can i reset the timer so it will repeatedly call the function ever 5 sec?

Share this post


Link to post
Share on other sites



$AutoHeal = 1
        $HealPotTimer = TimerInit()
    While 1
         If $AutoHeal = 1 And TimerDiff($HealPotTimer) >= 5000
               Heal()
           $HealPotTimer = TimerInit()
         EndIF
        WEnd
        Func Heal()
             WinActivate("Untitled - Notepad")
             Send("z")
        EndFunc

Im not looking for you to critique the code, im just looking to see why its not working. This isn't even the code im using so im not even sure if it works. Im just trying to give an example of what im trying to do.

Now on to the problem. It will only send the z key once after the timer has went off.

How can i reset the timer so it will repeatedly call the function ever 5 sec?

One you add a "then" in your "if-then" statement this segment of code will actually run. When it runs, it does trigger every 5 seconds like it's supposed to.

$AutoHeal = 1
$HealPotTimer = TimerInit()
While 1
    If $AutoHeal = 1 And TimerDiff($HealPotTimer) >= 5000 then 
           Heal()
       $HealPotTimer = TimerInit()
    EndIF
WEnd

Func Heal()
     WinActivate("Untitled - Notepad")
     Send("z")
EndFunc

My Programs[list][*]Knight Media Player[*]Multiple Desktops[*]Daily Comics[*]Journal[/list]

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0