Sign in to follow this  
Followers 0
mcgill

Countdown Timer with the option to add Time

5 posts in this topic

Looking for a countdown timer to be used with applying certain installations prior to reaching zero/no time left. I am not looking for a countup function. With this function I would like to be able to add time to it incase a user wants to increase the countdown timer, example being countdown timer of 60 minutes/1 hour, user wants to increase by 60 minutes/1 hour. The only information I have come across on the forums is for minutes and seconds only. Any helps/assistance in the right direction would be great, thanks

Example on forums:

*******************

$new = TimerDiff ($timer)

$new = (60*60*1000)-$new

$seconds = Round ($new/1000)

$newMin = Floor ($seconds/60)

$newSec = Mod ($seconds, 60)

If $newSec < 10 Then $newSec = "0"&$newSec

$LabelTime = $newMin & ":" & $newSec

GUICtrlSetData ($TimeLimit, $LabelTime)

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Search the Example Scripts forum with the keywords countdown timer. I'm sure thru the lengthy results page you'll find several posts that help you out.

Edited by somdcomputerguy

- Bruce /*somdcomputerguy */  If you change the way you look at things, the things you look at change.

Share this post


Link to post
Share on other sites

Try this:

#include <GUIConstantsEx.au3>
Opt('MustDeclareVars', 1)

Global $msg
Global $hGUI = GUICreate("Simple Countdown by UEZ 2011", 350, 150)
Global $label = GUICtrlCreateLabel("", 30, 30, 260, 80)
;~ GUICtrlSetBkColor(-1, 0x808080)
GUICtrlSetFont(-1, 50, 400)
Global $button = GUICtrlCreateButton("Add 1h", 295, 120, 50)
GUISetState()

Global $countdown = 1 ;minutes for countdown
Global $seconds = $countdown * 60 ;convert to seconds

Countdown()
AdlibRegister("Countdown", 1000)

Do
    $msg = GUIGetMsg()
    Switch $msg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $button
            $seconds += 3600
    EndSwitch
Until False

AdlibUnRegister("Countdown")
GUIDelete($hGUI)
Exit

Func Countdown()
    Local $sec, $min, $hr
    $sec = Mod($seconds, 60)
    $min = Mod($seconds / 60, 60)
    $hr = Floor($seconds / 60 ^ 2)
    GUICtrlSetData($label, StringFormat("%02i:%02i:%02i", $hr, $min, $sec))
    If $seconds <= 0 Then
        AdlibUnRegister("Countdown")
        MsgBox(0, "Information", "Countdown reached 00:00:00")
        Exit
    EndIf
    $seconds -= 1
EndFunc

Br,

UEZ

1 person likes this

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Share this post


Link to post
Share on other sites

Thank you UEZ, your assistance is much appreciated.

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