Jump to content

Timer


Joke758
 Share

Recommended Posts

here's a nice timer I made:

;By Joke758
#include <GUIConstants.au3>

$Form1 = GUICreate("AutoIt Timer", 179, 40, 192, 125)
$Label1 = GUICtrlCreateLabel("0 day(s) 00:00:00", 8, 8, 162, 28)
GUICtrlSetFont(-1, 14, 800, 0, "MS Sans Serif")
GUISetState(@SW_SHOW)
$time = TimerInit ( )
AdlibEnable ( "timer", 1000 )
While 1
    $msg = GuiGetMsg()
    Select
    Case $msg = $GUI_EVENT_CLOSE
        ExitLoop
    EndSelect
WEnd
Exit

Func timer()
    Local $tome
    Local $sec = StringRight ( GuiCtrlread ( $label1 ), 2 )
    Local $min = StringMid ( GuiCtrlread ( $label1 ), StringInStr ( GuiCtrlRead ( $label1 ), ":", 0, -1 )-2, 2 )
    Local $hur = StringMid ( GuiCtrlread ( $label1 ), StringInStr ( GuiCtrlRead ( $label1 ), ":" )-2, 2 )
    Local $day = StringLeft (GuiCtrlread ( $label1 ), StringInStr ( GuiCtrlread ( $label1 ), " " )-1 )
    
    Local $s
    Local $m
    Local $h

    $sec = int(TimerDiff ( $time ) / 1000)

    If $sec >= 60 Then
        $sec = 0
        $time = TimerInit()
        $min = $min + 1
    EndIf
    
    If $min >= 60 Then
        $min = 0
        $hur = $hur + 1
    EndIf
    
    If $hur >= 24 Then
        $hur = 0
        $day = $day + 1
    EndIf
    
    If StringLen ($sec) = 1 Then
        $s = '0'&$sec
    Else
        $s = $sec
    EndIf
    
    If StringLen ($min) = 1 Then
        $m = '0'&$min
    Else
        $m = $min
    EndIf
    
    If StringLen ($hur) = 1 Then
        $h = '0'&$hur
    Else
        $h = $hur
    EndIf
    
    $tome = $day & " day(s) " & $h & ":" & $m & ":" & $s 
    
    GuiCtrlSetData ( $label1, $tome )

EndFunc

[u]My Programs:[/u]Word Search Creator - Make your own Word SearchShortHand - Hide a secret message in a jpg fileHex Editor - Edit your Binary fileIncrease file size - Increase the size of any filesArt Generator - A program that generate random picture[u]My Functions:[/u]16-Bits Hash - My Hash function similar to MD5Probabilities - My probabilities function (factorial, permuation, combination)_GetDate() - Convert a date to a day of the week_Base(), _Dec() - Convert a number in any base (bin, oct, hex, dec). Create your own!

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...