Jump to content

How can I make countdown timer?


kuebk
 Share

Recommended Posts

I want to make countdown timer, from 15:00 [minutes] to 00:00 - and when it reach 00:00 I want sound to be played, could anyone help me with this?

Found nothing in help about countdown timer, I want to use it in GUI. :P

Thanks - kuebk.

Link to comment
Share on other sites

#include <GUIConstants.au3>

#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("AForm1", 122, 42, 438, 156)
$Label1 = GUICtrlCreateLabel("15:00", 8, 8, 43, 17)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

$time=TimerInit()
While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
    
    $new = TimerDiff ($time)
    $new = (15*60*1000)-$new
    $seconds = Round ($new/1000)
    $newMin = Floor ($seconds/60)
    $newSec = Mod ($seconds, 60)
    If $newSec < 10 Then $newSec = "0"&$newSec
    GUICtrlSetData ($Label1, $newMin&":"&$newSec)
WEnd

handy math functions there

The cake is a lie.www.theguy0000.com is currentlyUP images.theguy0000.com is currentlyUP all other *.theguy0000.com sites are DOWN

Link to comment
Share on other sites

maybe you can help me, i need something like this

i need a clock and if time = $timetowakeup then play sound...

i have been messing around with this script...but i dont understand why it not work

#include <Date.au3>
Global $Sec, $Min, $Hour, $Time
; calculate with time
$StartTicks = _TimeToTicks(@HOUR,@MIN,@SEC)
; calculate 45 minutes later
$EndTicks = $StartTicks 
_TicksToTime($EndTicks,$Hour,$Min,$Sec)
MsgBox(262144,'' , 'New Time:' &  $Hour & ":" & $Min & ":" & $Sec)
MsgBox(0,"time",""&@HOUR&@MIN&@SEC)


#include <Date.au3>

While 1
    Global $Sec, $Min, $Hour, $Time
    if _TimeToTicks() = "191255" Then ;260000
        MsgBox(0,"wake","up")
    EndIf

WEnd
Link to comment
Share on other sites

  • 1 year later...

No need to include Date.au3 twice :)

And for the sound, into the if statement about when it's complete.. add something like this in:

$fileName = FileOpen(beep.wav)

SoundPlay($fileName, 0)

Change beep.wav to whatever sound file you want....

~Fr3shY

Link to comment
Share on other sites

  • Developers

No need to include Date.au3 twice :o

And for the sound, into the if statement about when it's complete.. add something like this in:

Change beep.wav to whatever sound file you want....

~Fr3shY

No need to answer an 2 years old question as I doubt they will be waiting for it.

Jos :)

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

  • 2 years later...

I know old topic but I thought I'd add my own sample. Same as above but using a function and Tool Tips.

Not sure if it'll show up 100% but what the hell. I did need this information and hope I can help others

HotKeySet("{PAUSE}", "TogglePause")
fncPauseTime (2, " =================== " & @LF & _
        "---  Web page Reload Failed  --- " _
      & @LF & " --- Forced Pause till next try --- "_
      & @LF & " ************************* ", 3)
Func fncPauseTime($TimeToPause, $Message, $Warning)
Dim $PauseLeft = 1, $Time, $TTLSec, $Sec, $Min
    $Time = TimerInit()
    $Paused = Not $Paused
    While $PauseLeft > 0 And $Paused
          Sleep(500)
          $PauseLeft = TimerDiff($Time)
          $PauseLeft = ($TimeToPause * 60 * 1000) - $PauseLeft
           $TTLSec = Round($PauseLeft / 1000)
           $Min = Floor($TTLSec / 60)
           $Sec = Mod($TTLSec, 60)
           If $Sec < 10 Then $Sec = "0" & $Sec
           ToolTip($Message & @LF & "   Waiting - " & $Min & ":" & $Sec & "  minutes" & @LF & _
                   "Press {Pause} - to continute.", 400, 30, _
                  " Paused for " & $TimeToPause & " Minutes", $Warning)
     WEnd
     If $Paused Then $Paused = Not $Paused
     ToolTip("")
EndFunc   ;==>fncPauseTime
Func TogglePause()
     $Paused = Not $Paused
     While $Paused
            ToolTip("************************************" & @CRLF & _
                  "*        Program is Paused        *" & @CRLF & _
                   "************************************" & @CRLF _
                   , 400, 30, " Paused - Press {Pasue} again" , 2, 0)
            Sleep(400)
     WEnd
     ToolTip("")
EndFunc   ;==>TogglePause
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...