Sign in to follow this  
Followers 0
oozma

14min time on action?

6 posts in this topic

Hi all,

I am looking for a way to perform an action every 14 minutes mid-script.

I currently have one function being called in my script that performs a series of keypresses and clicks in a while 1=1 loop, but I want to throw in that it calls a different function every 14 minutes.

I've looked through the timer options but it's a little confusing to me as I'm still a bit new to this. One option is looping the function X amount of times to equal 14 minutes, but that number is so high I can't even begin to count it.

Any advice would be very much appreciated >_< thank you!

Share this post


Link to post
Share on other sites



sleep(840000) will wait 14 min. put it in a loop and after that call the function. That is it.

Share this post


Link to post
Share on other sites

Share this post


Link to post
Share on other sites

Just call the _check_timer occasionally. Thanks for the boost Brett. : )

; initialization of your stuff
$timer = TimerInit()

While 1
   ; Your stuff
   _check_timer()
   ; more of your stuff
   _check_timer()
   ; more of your stuff
   _check_timer()
Wend


Func _check_timer()
   If TimerDiff($timer) >= 840000 Then
      $timer = TimerInit()
      _fire_timer()
   endif
EndFunc

Func _fire_timer()
   ; Logic that goes once every 14 minutes goes here
EndFunc

Share this post


Link to post
Share on other sites

Thanks >_< That worked perfectly with a few mods from my stuff. Appreciate it.

Share this post


Link to post
Share on other sites

Hi, sorry to bump this up again but I have one more question. Currently with using the above, the script is working excellent. One slight problem... every 4 minutes or so (I lowered the time a bit) it is pressing the key "4" - at all times.

I have a hotkey set to turn the script on or off on demand, but the timer and '4' seem to run nonstop even if it's off.

Is there a way to only start the timer when I push the 'start' hotkey, and then stop the timer and the '4' from being sent when I push the 'stop' hotkey? I know WHY it's doing it, but when I attempt to fix it, I get a syntax check error

WARNING: $timer: possibly used before declaration.

Below is what I have...

HotKeySet("!1","Start")
HotKeySet("!3","Stop")
Global $go = false

Func start()
    $go = True
EndFunc

    $timer = TimerInit()

Func stop()
    $go = False
EndFunc

while 1
    check()
    sleep(50)
run()
sleep(50)
wend
    
Func check()
   If TimerDiff($timer) >= 440000 Then
      $timer = TimerInit()
      _fire_timer()
   endif
EndFunc

Func _fire_timer()
   sleep(1000)
   send("4")
   sleep(2000)
EndFunc

Func run()
    if $go = true Then
MouseDown("left")
sleep(2500)
MouseUp("Left")
Send("2")
Send("2")
Send("2")
Send("2")
Send("2")
Send("2")
sleep(1000)
Send("1")
sleep(1000)
    EndIf
EndFunc

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