Jump to content

How to build a 60 second delay timer?


Recommended Posts

Can someone help me get on the right track to build a 60 second delay timer..

$begin = TimerInit()
sleep(3000)
$dif = TimerDiff($begin)
MsgBox(0,"Time Difference",$dif)

I am lost... what I need is to send the script off to do a job and it will return via a For loop after its job is done. If it does not return from the job by the end of 60 seconds then I know it has fallen into a hole and something is wrong.. it should at the end of the 60 seconds make the tada sound... Here is a rough idea of what i am attempting...

For $i = 1 to 100

start 60 second Timer

dowork()

Turn time off so alarm does not sound if 60 seconds has not passed

Next

If the timer times out, it will play the tada sound..

SoundPlay("tada.wav", 0)

So basically the system is in a loop and the dowork() function takes approx 60 seconds..

IF it has not returned to the for next loop in 60 seconds than I must be alerted..

The timer must allow the system to go out and do its normal thing... so I cannot use a Sleep commmand

as that will stop the program until the sleep is over..

Maybe I can do it myself with just a little push in the right direction.

Link to comment
Share on other sites

That is fantastic... thanks a lot...

Question: Do you know whey it activates the alarm up to 7 times as you click the ok button..

When the "WoW Problem pops up and you click ok.. I would assume it would just repeat twice and stop

since the loop is for 2 tymes... but it pops up 7 times before getting quiet... is that normal?

I can use it this way, but its confusing... any ideas?

Even when I set the loop for 1 to 1 it still popped up 7 times... weird..

For $i = 1 to 2
    AdlibRegister('alarm', 3000)
    dowork($i)
    AdlibUnRegister('alarm')
Next

Func alarm()
SoundPlay("tada.wav", 0)
Msgbox(0,"","Wow Problem..")
EndFunc


; Does not sound the alarm
Func dowork($i)
ConsoleWrite("This is test " & $i & @CRLF)
Sleep(2000)
EndFunc

; Sounds the alarm..
Func dowork($i)
ConsoleWrite("This is test " & $i & @CRLF)
Sleep(3100)
EndFunc
Edited by tommytx
Link to comment
Share on other sites

Question: Do you know whey it activates the alarm up to 7 times as you click the ok button..

When the "WoW Problem pops up and you click ok.. I would assume it would just repeat twice and stop

since the loop is for 2 tymes... but it pops up 7 times before getting quiet... is that normal?

I can use it this way, but its confusing... any ideas?

Even when I set the loop for 1 to 1 it still popped up 7 times... weird..

This is a timing issue.

AdlibRegister('alarm', 3000) will run every 3000 ms. So while you wait to click the Ok button it will try and run again.

The MsgBox will hold that function until you click the ok button.

You could add a 1 in your msgboz like :Msgbox(0,"","Wow Problem..",1)

As to the part that is not sounding the alarm. Sleep 2000 is faster than the 3000 before the alarm must kick in.

Edited by JoHanatCent
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...