Jump to content

Chronometer


Darkonen
 Share

Recommended Posts

  • Developers

Posted a while ago here, maybe that helps?:

#include <GUIConstants.au3>
#include <Date.au3>
opt("TrayIconDebug",1)
Global $Secs, $Mins, $Hour, $Time
;Create GUI
GUICreate("My Timer", 200, 200)
GUICtrlCreateLabel("00:00:00", "80", "80")
GUISetState()
;Start timer
$timer = TimerInit()
AdlibEnable("Timer", 50)
;
While 1
;FileWriteLine("debug.log",@min & ":" & @sec & " ==> before")
  $msg = GUIGetMsg()
;FileWriteLine("debug.log",@min & ":" & @sec & " ==> after")
  Select
     Case $msg = $GUI_EVENT_CLOSE
        Exit
  EndSelect
Wend
;
Func Timer()
  _TicksToTime(Int(TimerDiff($timer)), $Hour, $Mins, $Secs )
  Local $sTime = $Time; save current time to be able to test and avoid flicker..
  $Time = StringFormat("%02i:%02i:%02i", $Hour, $Mins, $Secs)
  If $sTime <> $Time Then ControlSetText("My Timer", "", "Static1", $Time)
EndFunc;==>Timer
Edited by JdeB

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

A simple clock:

#Include <Date.au3>
#include <GUIConstants.au3>

AdlibEnable ( "_time" , 1000 )
GUICreate( "Watch", 100, 30, -1, -1, $WS_Caption, $WS_EX_TOPMOST )
$Clock = GUICtrlCreateLabel( "Watch", 10, 10, 50 )
GUISetState()

While 1
 If GUIGetMsg() = $GUI_EVENT_CLOSE then _Exit();ESC to exit
WEnd

Func _time()
GUICtrlSetData ( $Clock, _NowTime(5) )
EndFunc

Func _Exit()
GUIDelete()
Exit
EndFunc
A simple stopwatch
#include <GUIConstants.au3>
#include <Date.au3>

Dim $Ver = "Stopwatch"
HotKeySet( "!x", "_Exit" );Alt+X to exit
GUICreate( $Ver, 100, 30, -1, -1, $WS_Caption, $WS_EX_TOPMOST )
$Clock = GUICtrlCreateLabel( $Ver, 25, 10, 50 )
GUISetState()

For $i = 0 To 86400; max. 24h
$Time = _DateAdd ( "s", $i, "2000/01/01 00:00:00" )
$Dif = StringSplit ( $Time, " " )
GUICtrlSetData ( $Clock, $Dif[2] )
Sleep( 1000 )
Next

Func _Exit()
MsgBox( 16, $Ver, " stopped at:" & @LF & $Dif[2],  5 ) 
GUIDelete()
Exit
EndFunc

Link to comment
Share on other sites

Here is another one with an alarm function. I can't remember who wrote it but it was not me.

#include <GuiConstants.au3>
Global $sec = @SEC, $minute, $hour, $light, $time, $clocklabel
opt("WinWaitDelay", 100)
opt("WinTitleMatchMode", 4)
opt("WinDetectHiddenText", 1)
opt("MouseCoordMode", 0)
GUICreate("Max's Clock", 200, 50, (@DesktopWidth - 188) / 2, (@DesktopHeight - 59) / 2)
$clocklabel = GUICtrlCreateLabel("Loading...", 5, 5, 190, 40, 0x1000)
GUICtrlSetFont($clocklabel, 24)
GUISetState()
While 1
    $msg = GUIGetMsg()
    If $msg = -3 Then
        ExitLoop
    ElseIf $sec <> @SEC Then
        GUICtrlSetData($clocklabel, TimeSet())
        AlarmCheck(TimeSet())
    EndIf
WEnd
Exit
Func AlarmCheck($time)
If $time = "6:10:00 PM"Then
MsgBox(0,"","Alarm Message");Alarm function(configure how wanted)
EndIf
EndFunc ;==>AlarmCheck
Func TimeSet()
    $light = " AM"
    $hour = @HOUR
    $minute = @MIN
    $sec = @SEC
    If $hour = 0 Then
        $hour = 12
    ElseIf $hour = 12 Then
        $light = " PM"
    ElseIf $hour > 12 Then
        $hour = (@HOUR) - 12
        $light = " PM"
    EndIf
    $time = $hour & ":" & $minute & ":" & $sec & $light
    Return $time
EndFunc ;==>TimeSet


Time you enjoyed wasting is not wasted time ......T.S. Elliot
Suspense is worse than disappointment................Robert Burns
God help the man who won't help himself, because no-one else will...........My Grandmother

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