Sign in to follow this  
Followers 0

How to create a countdown timer in autoit?

39 posts in this topic

#1 ·  Posted (edited)

Hellow id just like to ask how to create a countdown timer in autoit

I started with this code: It was the GUI of this program

The timer has HH:MM:SS Hours/Minute/Seconds

Countdown Timer

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=D:\Program Files\koda_1.7.3.0\Forms\timer.kxf
$Form1 = GUICreate("Timer", 222, 119, 346, 191)
$Label1 = GUICtrlCreateLabel("00", 0, 8, 40, 41)
GUICtrlSetFont(-1, 24, 400, 0, "MS Sans Serif")
$Label2 = GUICtrlCreateLabel(":", 48, 8, 13, 41)
GUICtrlSetFont(-1, 24, 400, 0, "MS Sans Serif")
$Label3 = GUICtrlCreateLabel("00", 72, 8, 40, 41)
GUICtrlSetFont(-1, 24, 400, 0, "MS Sans Serif")
$Label4 = GUICtrlCreateLabel(":", 120, 8, 13, 41)
GUICtrlSetFont(-1, 24, 400, 0, "MS Sans Serif")
$Label5 = GUICtrlCreateLabel("00", 136, 8, 40, 41)
GUICtrlSetFont(-1, 24, 400, 0, "MS Sans Serif")
$Button1 = GUICtrlCreateButton("Start Countdown", 0, 64, 89, 33)
$Button2 = GUICtrlCreateButton("Stop Countdown", 104, 64, 97, 33)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
                Case $button1
                ;countdown timer start
                Case $button2
                ;countdown timer stop

    EndSwitch
WEnd

I dont use the Sleep() Function

...

I need codes :unsure:

Edited by GianAutoitprogrammer

Share this post


Link to post
Share on other sites



#2 ·  Posted

An example :

#include <WindowsConstants.au3>

Global $SS_CENTER, $_CompteArebour = 60000, $_Minutes, $_Seconds

$_GuiCountDown = GUICreate ( "CountDown...", 500, 200, @DesktopWidth/2 -250, @DesktopHeight/2 -100, $WS_EX_TOPMOST  )
GUISetBkColor ( 0xFFFF00 )
$TimeLabel = GUICtrlCreateLabel ( "", 35, -10, 480, 180, $SS_CENTER )
GUICtrlSetFont ( -1, 125, 800 )
GUISetState ( )
WinSetOnTop ( $_GuiCountDown, "", 1 )
$TimeTicks = TimerInit ( )

While 1
    _Check ( )
    Sleep ( 200 )
WEnd

Func _Check ( )
    $_CompteArebour -= TimerDiff ( $TimeTicks )
    $TimeTicks = TimerInit ( )
    Local $_MinCalc = Int ( $_CompteArebour / ( 60 * 1000 ) ), $_SecCalc = $_CompteArebour - ( $_MinCalc * 60 * 1000 )
    $_SecCalc = Int ( $_SecCalc / 1000 )
    If $_MinCalc <= 0 And $_SecCalc <= 0 Then
        GUISetBkColor ( 0xFF0000, $_GuiCountDown )
        GUICtrlSetData ( $TimeLabel, "Bye !" )
        Sleep ( 1000 )
        ; If @Compiled Then Shutdown ( 13 )
        Exit
    Else
        If $_MinCalc <> $_Minutes Or $_SecCalc <> $_Seconds Then
            $_Minutes = $_MinCalc
            $_Seconds = $_SecCalc
            GUICtrlSetData ( $TimeLabel, StringFormat ( "%02u" & ":" & "%02u", $_Minutes, $_Seconds ) )
            If $_Minutes = 0 And $_Seconds <= 10 Then
                Beep ( 1200, 100 )
                GUISetBkColor ( 0xA093FF, $_GuiCountDown )
            EndIf
        EndIf
    EndIf
EndFunc ;==> _Check ( )

AutoIt 3.3.14.0 X86 - SciTE 3.5.4WIN 8.1 X64

Share this post


Link to post
Share on other sites

#3 ·  Posted

thank You :unsure::>

Share this post


Link to post
Share on other sites

#4 ·  Posted

thank You :unsure::>

Is it as you like ? Posted Image


AutoIt 3.3.14.0 X86 - SciTE 3.5.4WIN 8.1 X64

Share this post


Link to post
Share on other sites

#5 ·  Posted

hey wakillon, the script that you posted doesnt have hours the script only has Minutes and seconds...

Share this post


Link to post
Share on other sites

#6 ·  Posted

I need a timer HH:MM:SS

Hours:Minutes:Seconds

I am going to build a client timer software for computer shops I mean a cafeagent like software... using autoit...

Share this post


Link to post
Share on other sites

#7 ·  Posted

Try understanding the script and it should be easy to adapt.


Visit the SciTE4AutoIt3 Download page for the latest versions                                                                 Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

#8 ·  Posted

GianAutoitprogrammer,

So far you have been "GianAutoitASKER" - this forum is not a request shop for everything you want in AutoIt. We expect YOU to do some of the work yourself. :>

wakillon has very kindly given you a a good chunk of code (as have others in other threads, including myself) - it is now up to YOU to develop those snippets. We are here to help you when you run into problems, but we are NOT here to write your code for you.

I would suggest you take a little time to learn a bit about AutoIt. Reading the Help file (at least the first few sections - Using AutoIt, Tutorials and the first couple of References) will help you enormously. You should also look at the excellent tutorials that you will find here and here - you will find other tutorials in the Wiki (the link is at the top of the page). There are even video tutorials on YouTube if you prefer watching to reading.

So over to you. Start writing your own scripts and you will find us ready and willing to help - keep asking for code and you will soon find that no-one will answer.

Your choice! :unsure:

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert - Easily convert date/time formats, including the language used
ExtMsgBox ------------- A highly customisable replacement for MsgBox
GUIExtender ----------- Extend and retract multiple sections within a GUI
GUIFrame -------------- Subdivide GUIs into many adjustable frames
GUIListViewEx -------- Insert, delete, move, drag, sort and edit ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ---------------- Scrolling tickertape GUIs
NoFocusLines --------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify -------------------- Small notifications on the edge of the display
Scrollbars -------------- Automatically sized scrollbars with a single command
StringSize -------------- Automatically size controls to fit text
Toast -------------------- Small GUIs which pop out of the notification area

Share this post


Link to post
Share on other sites

#9 ·  Posted

@jos which script wakillon script?

Share this post


Link to post
Share on other sites

#10 ·  Posted

@Melba23 I am helphing others since yesterday iam viewing the Genral help and Support and searching for the problems that I can solve... Sorry if I am asking too much :unsure:

I am just in a hurry...

Share this post


Link to post
Share on other sites

#11 ·  Posted

@Melba23 I am helphing others since yesterday iam viewing the Genral help and Support and searching for the problems that I can solve... Sorry if I am asking too much :unsure:

I am just in a hurry...

Allez au boulot !

Show us your adaptation of my countdown ! Posted Image


AutoIt 3.3.14.0 X86 - SciTE 3.5.4WIN 8.1 X64

Share this post


Link to post
Share on other sites

#12 ·  Posted

@Melba23 I am using autoit since last year but there are some funcrions that I cant understand so thats why I am asking here... But its okay, i am asking too much...

Share this post


Link to post
Share on other sites

#13 ·  Posted

and who knows I am just a second year high school...

Share this post


Link to post
Share on other sites

#14 ·  Posted

Search the 'Example Scripts' forum section using 'countdown' as the keyword..


- Bruce [font="'Lucida Console';"]/*somdcomputerguy */  If you change the way you look at things, the things you look at change.[/font]

Share this post


Link to post
Share on other sites

#15 ·  Posted

@somdcomputerguy I am now searching...

Share this post


Link to post
Share on other sites

#16 ·  Posted

Okay I think I cant create a countdown timer but I can call the sleep() function

Sleep(3600) ; 3600 ms = 1 hr

1hr countdown timer

...

Share this post


Link to post
Share on other sites

#17 ·  Posted

Good step. Read thru all the scripts you find. So while Jos was refering to the code that wakillon posted in this thread to help you, it will surely help you to read thru the many 'countdown' related scripts you will find in the Examples section. Soon the lightbulb above your head will be burning brightly! :>:unsure:


- Bruce [font="'Lucida Console';"]/*somdcomputerguy */  If you change the way you look at things, the things you look at change.[/font]

Share this post


Link to post
Share on other sites

#18 ·  Posted (edited)

Read thru the Help file too. Sleep(3600) will 'sleep' for slightly more than 3 and half seconds..They don't teach milliseconds until junior (3rd) year in your high school?<br>

Edited by somdcomputerguy

- Bruce [font="'Lucida Console';"]/*somdcomputerguy */  If you change the way you look at things, the things you look at change.[/font]

Share this post


Link to post
Share on other sites

#19 ·  Posted

tnx all of you for helping me :unsure:

Share this post


Link to post
Share on other sites

#20 ·  Posted (edited)

Have a look here:

Br,

UEZ

Edited by UEZ

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

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

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