Code : Tout sélectionner
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <Date.au3>
Opt( "MustDeclareVars", 1 )
Dim $Form1, $Heures, $Minutes, $Secondes, $Centieme,$Dixiemes, $Milliemes, $Start, $Hour, $Mins, $Secs, $timerdiff, $DepartChronometre, $nMsg, $i
Global $Paused, $Stop
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Chronomètre", 225, 116, 226, 216)
$Heures = GUICtrlCreateLabel("00", 8, 8, 42, 41)
GUICtrlSetFont(-1, 24, 800, 0, "MS Sans Serif")
$Minutes = GUICtrlCreateLabel("00", 59, 8, 42, 41)
GUICtrlSetFont(-1, 24, 800, 0, "MS Sans Serif")
$Secondes = GUICtrlCreateLabel("00", 109, 8, 42, 41)
GUICtrlSetFont(-1, 24, 800, 0, "MS Sans Serif")
$Centieme = GUICtrlCreateLabel("0", 179, 8, 23, 41)
GUICtrlSetFont(-1, 24, 800, 0, "MS Sans Serif")
$Dixiemes = GUICtrlCreateLabel("0", 159, 8, 23, 41)
GUICtrlSetFont(-1, 24, 800, 0, "MS Sans Serif")
$Milliemes = GUICtrlCreateLabel("0", 197, 8, 23, 41)
GUICtrlSetFont(-1, 24, 800, 0, "MS Sans Serif")
GUICtrlCreateLabel(":", 49, 8, 14, 41)
GUICtrlSetFont(-1, 24, 800, 0, "MS Sans Serif")
GUICtrlCreateLabel(":", 99, 8, 14, 41)
GUICtrlSetFont(-1, 24, 800, 0, "MS Sans Serif")
GUICtrlCreateLabel(":", 149, 8, 14, 41)
GUICtrlSetFont(-1, 24, 800, 0, "MS Sans Serif")
$Start = GUICtrlCreateButton("Start", 8, 56, 65, 49, 0)
$Stop = GUICtrlCreateButton("Stop", 80, 56, 65, 49, 0)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Start
GUIctrlSetState ( $Start, $GUI_DISABLE )
chronometre()
Case $Stop
GUICtrlSetState ( $start, $GUI_ENABLE )
stop()
EndSwitch
WEnd
Func chronometre()
$DepartChronometre = TimerInit()
While $nMsg <> $GUI_EVENT_CLOSE Or $nMsg <> $Stop
$i = Int(TimerDiff($DepartChronometre))
_TicksToTime( $i, $Hour, $Mins, $Secs)
GUICtrlSetData ( $Heures, $Hour )
GUICtrlSetData ( $Minutes, $Mins )
GUICtrlSetData ( $Secondes, $Secs )
$timerdiff = Int(TimerDiff($DepartChronometre))
GUICtrlSetData( $Milliemes, StringRight($timerdiff,1) )
GUICtrlSetData( $Centieme, StringTrimRight(StringRight($timerdiff,2),1))
GUICtrlSetData( $Dixiemes, StringTrimRight(StringRight($timerdiff,3),2))
WEnd
EndFunc
Func stop()
$Paused = NOT $Paused
While $Paused
sleep(100)
WEnd
EndFunc
While 1
Sleep ( 100 )
WEnd