

#cs Beispiel zum Anzeigen eines Timers
#include <GuiConstantsEx.au3>
#include <WindowsConstants.au3>
#include <WinAPI.au3>


HotKeySet("{NUMPAD0}", "d")
HotKeySet("{NUMPAD9}", "On_Exit")

Global $SS_CENTER, $hGUI, $aRadio[5], $hButton, $res
Global $TimeLabel_d, $TimeLabel
Global $TimeTicks_d, $TimeTicks
Global $_SecCalc_d, $_SecCalc_b, $_SecCalc_ob, $_SecCalc_or, $_SecCalc_tb, $_SecCalc_tr, $_SecCalc
Global $_Seconds_d, $_Seconds_b, $_Seconds_ob, $_Seconds_or, $_Seconds_tb, $_Seconds_tr, $_Seconds


$hGUI = GUICreate("LJT", 150, 190, 0, 0)
GUICtrlCreateLabel("Choose your resolution", 10, 10, 150, 20)


GUIStartGroup()
For $i = 0 To 4
	Local $res[5] = ["2560 x 1440", "1920 x 1080", "1600 x 900", "1280 x 720", "1024 x 768"]
    $aRadio[$i] = GUICtrlCreateRadio($res[$i], 55,  30 + ($i * 20), 100, 20)
Next
GUICtrlSetState($aRadio[0], $GUI_CHECKED)
$hButton = GUICtrlCreateButton("Start Overlay", 35, 150, 80, 30)
GUISetState()

While 1

    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $hButton
            ;GUISetState(@SW_HIDE, $hGUI)
            For $i = 0 To 4
                If GUICtrlRead($aRadio[$i]) = 1 Then
                    $res = $i
                    ExitLoop
                EndIf
            Next
            Timer()
	EndSwitch
	;Sleep(20)
WEnd

; -------------

Func Timer()
	Local $hRectangle_GUI = GUICreate("", @DesktopWidth, @DesktopHeight, 0, 0, $WS_POPUP, $WS_EX_TOOLWINDOW + $WS_EX_TOPMOST + $WS_EX_LAYERED + $WS_EX_TRANSPARENT)
	Local $hMaster_Mask = _WinAPI_CreateRectRgn(0, 0, @DesktopWidth, @DesktopHeight)
	$TimeLabel_d = GUICtrlCreateLabel ( "", @DesktopWidth/2-800, @DesktopHeight/2-250, 1600, 500);, $SS_CENTER )
	GUICtrlSetFont($TimeLabel_d, 250, 900, 0, "Georgia");hier die Schrifattribute des Timers vorgenen


	GUISetFont ( -1, 8, 200 )
	GuiCtrlSetColor($TimeLabel_d, 0xFF0000);hier die Schriftfarbe des Timer vorgeben


	GUISetBkColor(0xABCDEF)
	_WinAPI_SetLayeredWindowAttributes($hRectangle_GUI, 0xABCDEF, 255)
	GUISetState()
TimerOn()
EndFunc


Func TimerOn()
	Local Static $Zeit1, $Zeit2
	While 1
	$Zeit1 = @Min & ":" & @Sec; & ":" & @MSec
		Sleep(200)
	$Zeit2 = @Min & ":" & @Sec; & ":" & @MSec
	If $Zeit1 <> $Zeit2 Then GuiCtrlSetData($TimeLabel_d, $Zeit2)
	WEnd
EndFunc



Func On_Exit()
    Exit
EndFunc
#ce



#cs Stoppuhr von Oscar
#include <GUIConstantsEx.au3>
Opt('GUIOnEventMode', 1)


$hGui = GUICreate('Stoppuhr', 200, 100)
GUISetOnEvent($GUI_EVENT_CLOSE, '_End')
Global $ahTime[4], $aOld[4], $iTimer, $fPause = False
For $i = 0 To 3
$ahTime[$i] = GUICtrlCreateLabel(StringFormat('%0' & 2 + Number($i = 3) & 'i', 0), 40 + $i * 30, 20, 30, 20)
GUICtrlSetFont(-1, 14, 400, 0, 'Tahoma', 5)
If $i < 3 Then
GUICtrlCreateLabel(':', 62 + $i * 30, 20, 10, 20)
GUICtrlSetFont(-1, 14, 400, 0, 'Tahoma', 5)
EndIf
Next
$hStart = GUICtrlCreateButton('Start', 10, 60, 50, 25)
GUICtrlSetOnEvent(-1, '_Start')
$hPause = GUICtrlCreateButton('Pause', 70, 60, 50, 25)
GUICtrlSetOnEvent(-1, '_Pause')
GUICtrlSetState(-1, $GUI_DISABLE)
$hStopp = GUICtrlCreateButton('Stopp', 130, 60, 50, 25)
GUICtrlSetOnEvent(-1, '_Stopp')
GUICtrlSetState(-1, $GUI_DISABLE)
GUISetState()


While Sleep(1000)
WEnd


Func _End()
Exit
EndFunc ;==>_End


Func _Start()
GUICtrlSetState($hStart, $GUI_DISABLE)
GUICtrlSetState($hStopp, $GUI_ENABLE)
GUICtrlSetState($hPause, $GUI_ENABLE)
$iTimer = TimerInit()
AdlibRegister('_ShowTime', 10)
EndFunc ;==>_Start


Func _Pause()
$fPause = Not $fPause
Switch $fPause
Case True
AdlibUnRegister('_ShowTime')
GUICtrlSetData($hPause, 'Weiter')
Case False
AdlibRegister('_ShowTime', 10)
GUICtrlSetData($hPause, 'Pause')
EndSwitch
EndFunc ;==>_Pause


Func _Stopp()
AdlibUnRegister('_ShowTime')
_ShowTime()
GUICtrlSetState($hStart, $GUI_ENABLE)
GUICtrlSetState($hStopp, $GUI_DISABLE)
GUICtrlSetState($hPause, $GUI_DISABLE)
EndFunc ;==>_Stopp


Func _ShowTime()
Local $aTime[4], $iTicks = TimerDiff($iTimer)
$aTime[2] = Int($iTicks / 1000)
$aTime[3] = Int($iTicks - $aTime[2] * 1000)
$aTime[0] = Int($aTime[2] / 3600)
$aTime[2] = Mod($aTime[2], 3600)
$aTime[1] = Int($aTime[2] / 60)
$aTime[2] = Mod($aTime[2], 60)
For $i = 0 To 3
If $aTime[$i] <> $aOld[$i] Then GUICtrlSetData($ahTime[$i], StringRight('00' & $aTime[$i], 2 + Number($i = 3)))
Next
$aOld = $aTime
EndFunc ;==>_ShowTime
#ce



#cs Stoppuhr von Veronesi

;https://autoit.de/index.php?thread/21058-stoppuhr-verbesserungsvorschl%C3%A4ge/&postID=170530&highlight=Stoppuhr#post170530
#include <WindowsConstants.au3>
#include <Date.au3>


Dim $Start = False, $Timer = 0, $tmpTimer = 0, $LastTimer = 0
Dim $iHours = 0, $iMins = 0, $iSecs = 0, $iHsecs = 0


Opt("GUIOnEventMode",1) ;Enable Interrupts for GUI
$GUI = GUICreate("Stoppuhr", 325, 126, 214, 139, 0x00080000, 0x00000008) ;Create GUI with Topmost ID
$Stoppuhr = GUICtrlCreateLabel("Stoppuhr", 8, 8, 135, 41)
GUICtrlSetFont(-1, 26, 400, 0, "Arial")
$Zeit = GUICtrlCreateLabel("00:00:00.00", 8, 56, 178, 41)
GUICtrlSetFont(-1, 26, 400, 0, "Arial")
GUICtrlSetColor(-1, 0xFF0000)
$StartStopp = GUICtrlCreateButton("Start", 225, 8, 89, 41, $WS_GROUP)
GUICtrlSetFont(-1, 16, 400, 0, "Arial")
$Reset = GUICtrlCreateButton("Reset", 225, 56, 89, 41, $WS_GROUP)
GUICtrlSetFont(-1, 16, 400, 0, "Arial")


GUICtrlSetOnEvent($StartStopp, "StartStopp") ;Create events for Buttons
GUICtrlSetOnEvent($Reset, "Reset")
GUISetOnEvent(-3, "End") ;Create Event for {ESC} and Close
GUISetState(@SW_SHOW) ;Show GUI


While Sleep(50) ;Main Loop
If $Start Then ;Only if start is pressed....
$tmpTimer = (TimerDiff($Timer)) + $LastTimer
Convert() ;Convert ticks to time and splitt it into HH:MM:SS.hh
GUICtrlSetData($Zeit, $iHours & ":" & $iMins & ":" &$iSecs & "." & $iHsecs) ;Update GUI
EndIf
WEnd


Func StartStopp() ;Interrupt for start/stop buttons
If $Start Then ;Stop button pressed
GUICtrlSetData($StartStopp, "Start") ;Change button text
$tmpTimer = (TimerDiff($Timer)) + $LastTimer
$LastTimer = $tmpTimer
$Start = False
Convert() ;Convert ticks to time and splitt it into HH:MM:SS.hh
GUICtrlSetData($Zeit, $iHours & ":" & $iMins & ":" &$iSecs & "." & $iHsecs) ;Update GUI
Else
GUICtrlSetData($StartStopp, "Stopp") ;Start button pressed
$Start = True
$Timer = TimerInit()
EndIf
EndFunc ;==>StartStopp


Func Reset() ;Resets GUI
GUICtrlSetData($Zeit, "00:00:00.00")
$LastTimer = 0
$Timer = TimerInit()
EndFunc ;==>Reset


Func Convert() ;Convert ticks to time and splitt it into HH:MM:SS.hh
_TicksToTime($tmpTimer, $iHours, $iMins, $iSecs)
$iHsecs = Round(($tmpTimer - (($iHours * 3600000) + ($iMins * 60000) + ($iSecs * 1000))) / 10)
If $iHours < 10 Then $iHours = "0" & $iHours
If $iMins < 10 Then $iMins = "0" & $iMins
If $iSecs < 10 Then $iSecs = "0" & $iSecs
If $iHsecs < 10 Then $iHsecs = "0" & $iHsecs
EndFunc ;==>Convert

;~ Oscar version von Convert
;~ Die Convert-Funktion würde ich lieber so schreiben:
;~ Func _NewTicksToTime($iTicks)
;~ Local $iHours, $iMins, $iSecs = Int($iTicks / 1000), $iMSecs = $iTicks - $iSecs * 1000
;~ $iHours = Int($iSecs / 3600)
;~ $iSecs = Mod($iSecs, 3600)
;~ $iMins = Int($iSecs / 60)
;~ $iSecs = Mod($iSecs, 60)
;~ Return StringFormat('%02i:%02i:%02i.%03i', $iHours, $iMins, $iSecs, $iMSecs)
;~ EndFunc ;==>_NewTicksToTime
;~ Ist aber letztendlich der eigene Programmierstil.


Func End() ;Exit
Exit
EndFunc ;==>End
#ce



#cs Zeitspiel 5 Sekundenschätzen Den Urheber hiervon was ich leider nicht mehr
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
Opt("GUIOnEventMode", 1)
$gesamt = 0
$1 = 0
Global $start, $UsedTime, $diff_Alt = 0,$blende = 0
Global $SetTime = False, $Break = False, $Pause = False, $Run = True
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("5 Seconds", 223, 202, 192, 124)
GUISetBkColor(0x000000)
GUISetOnEvent($GUI_EVENT_CLOSE, "Form1Close")
GUISetOnEvent($GUI_EVENT_MINIMIZE, "Form1Minimize")
GUISetOnEvent($GUI_EVENT_MAXIMIZE, "Form1Maximize")
GUISetOnEvent($GUI_EVENT_RESTORE, "Form1Restore")


$sekunden = GUICtrlCreateLabel("", 85, 48, 100, 36)
GUICtrlSetFont($sekunden, 32, 800, 0, "Terminal")
GUICtrlSetColor($sekunden, 0x00FF00)


$blende = GUICtrlCreateLabel("Blende", 32, 40, 138, 41)
GUICtrlSetState ( $blende, $GUI_HIDE )

$anleitung = GUICtrlCreateLabel("Stoppe den Timer nach genau 5 Sekunden!", 16, 160, 199, 50)
GUICtrlSetFont($anleitung, 9, 400, 0, "Terminal")
GUICtrlSetColor($anleitung, 0x00FF00)


$gobutt = GUICtrlCreateButton("Go!", 40, 112, 121, 33, $WS_GROUP)
GUICtrlSetFont($gobutt, 12, 400, 0, "Terminal")
GUICtrlSetBkColor($gobutt, 0x00FF00)
GUICtrlSetOnEvent($gobutt, "StopgobuttClick")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###


While 1


If $SetTime Then
Time()

EndIf
WEnd




Func Form1Close()
Exit
EndFunc
Func Form1Maximize()


EndFunc
Func Form1Minimize()


EndFunc
Func Form1Restore()


EndFunc


Func StopgobuttClick()

$Run = Not $Run
If $Run Then
$SetTime = False

GUICtrlSetData($gobutt,"Go!")

Time()
GUICtrlSetData($sekunden,$gesamt)

GUICtrlSetState ( $blende, $GUI_HIDE )
GUICtrlSetColor($sekunden, 0x00FF00)
Else


GUICtrlSetData($gobutt,"Stop!")
GUICtrlSetData($sekunden,"")
$SetTime = True
$start = TimerInit()
EndIf

EndFunc




Func Time()
GUICtrlSetState ( $blende, $GUI_HIDE )
If $gesamt > 2 Then

GUICtrlSetState ( $blende, $GUI_SHOW )
EndIf
$bisher = TimerDiff($start)
$bisher = $bisher / 1000
$gesamt = Round($bisher, 2)
GUICtrlSetData($sekunden,$gesamt)
Sleep(100)

EndFunc
#ce



#cs;Timer von McPoldy Alias Blog4IT Alias Jens Kröger
#include <Date.au3>
HotKeySet("^x","_Exit")
Global $hour,$min,$sec
$start = TimerInit(); - 10000000000
;clipput(Timerinit())
;Global $start2 = 18268656782076 - 5000000000


While 1
Sleep(995)
_TicksToTime(Int(TimerDiff($start)),$hour,$min, $sec)
$hsec = Int((TimerDiff($start) - ($hour*3600*1000 + $min*60*1000 + $sec*1000))/10)
$min = StringRight('0' & $min,2)
$sec = StringRight('0' & $sec,2)
$hour = StringRight("0" & $hour,2)
ToolTip($hour & ":" & $min & ':' & $sec & "," & $hsec)
WEnd


Func _Exit()
Exit
EndFunc
#ce



#cs Fussballtimer Seubo
#include <Date.au3>
#include <GUIConstantsEx.au3>
$hGUI = GUICreate("Fußball-Stoppuhr",350,145,0,0)
GUISetFont(16)
$idUhr = GUICtrlCreateLabel("00:00:00",0,0,350,75,BitOR(0x01,0x200))
GUICtrlSetFont(-1,22)
GUICtrlSetState(-1,$GUI_DISABLE)
$idCheckBox = GUICtrlCreateCheckbox("Immer im Vordergrund",200,127,180,15)
GUICtrlSetState(-1,$GUI_CHECKED)
GUICtrlSetFont(-1,10)
$idStart = GUICtrlCreateButton("Anpfiff!",0,75,350,50)


$idHalbZeit = GUICtrlCreateButton("Zur Halbzeit springen...",0,75,350,50)
GUICtrlSetState(-1,$GUI_HIDE)
$idStartHalbZeit = GUICtrlCreateButton("Anpfiff nach Halbzeit",0,75,350,50)
GUICtrlSetState(-1,$GUI_HIDE)
$idStop = GUICtrlCreateButton("Schlusspfiff!",0,75,350,50)
GUICtrlSetState(-1,$GUI_HIDE)


WinSetOnTop($hGUI,"",1)
$bOntOp = True


GUISetState()


While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case -3
Exit
Case $idCheckBox
$bOntOp = Not $bOntOp
WinSetOnTop($hGUI,"",$bOntOp)
Case $idStart
GUICtrlSetState($idStart,$GUI_HIDE)
GUICtrlSetState($idHalbZeit,$GUI_SHOW)
GUICtrlSetState($idUhr,$GUI_ENABLE)
$t = TimerInit()
AdlibRegister("_Sync",75)
Case $idHalbZeit
AdlibUnRegister("_Sync")
$t = TimerInit() - _TimeToTicks(1,4,26)*10000+950000 ; Keine Ahnung. Ich habs nicht anders hinbekommen xD
_Sync()
GUICtrlSetState($idHalbZeit,$GUI_HIDE)
GUICtrlSetState($idStartHalbZeit,$GUI_SHOW)
Case $idStartHalbZeit
$t = TimerInit() - _TimeToTicks(1,4,26)*10000+950000
AdlibRegister("_Sync",75)
GUICtrlSetState($idStartHalbZeit,$GUI_HIDE)
GUICtrlSetState($idStop,$GUI_SHOW)
Case $idStop
$t = TimerInit() - (_TimeToTicks(1,4,26)*10000)*2+1900000
_Sync()
AdlibUnRegister("_Sync")
GUICtrlSetState($idStart,$GUI_SHOW)
GUICtrlSetState($idStop,$GUI_HIDE)
GUICtrlSetState($idUhr,$GUI_DISABLE)
EndSwitch
WEnd


Func _Sync()
$aSplit = StringSplit(StringFormat("%.2f",TimerDiff($t)/1000),".",2)
$iMin = Floor($aSplit[0] / 60)
$iSec = Mod($aSplit[0],60)
GUICtrlSetData($idUhr,StringFormat("%.2d",$iMin)&":"&StringFormat("%.2d",$iSec)&":"&$aSplit[1])
EndFunc
#ce



#cs Fussbaltimer von Prog@ndy
;https://autoit.de/index.php?thread/17179-stoppuhr-f%C3%BCr-fu%C3%9Fball/&postID=133645#post133645
#include<DAte.au3>
#include<GUIListBox.au3>
#include<GUIConstantsEx.au3>
#include<WindowsConstants.au3>
#include<StaticConstants.au3>
$hGUI = GUICreate("Fussballtimer", 400, 300)
$lstZeiten = GUICtrlCreateList("", 10, 10, 380, 100, $WS_VSCROLL)
$lblUhr = GUICtrlCreateLabel("00:00.00", 10, 110, 380, 70,$SS_CENTER)
GUICtrlSetTip(-1, "reguläre Spielzeit")
GUICtrlSetFont(-1, 50, 800)
$lblNachspielzeit = GUICtrlCreateLabel("00:00.00", 10, 180, 180, 35,$SS_CENTER)
GUICtrlSetTip(-1, "Nachspielzeit")
GUICtrlSetFont(-1, 20, 600)
GUICtrlSetColor(-1, 0xAA5555)
$lblGesamt = GUICtrlCreateLabel("00:00.00", 200, 180, 180, 35,$SS_CENTER)
GUICtrlSetColor(-1, 0x999955)
GUICtrlSetFont(-1, 20, 600)
GUICtrlSetTip(-1, "Nachspielzeit + reguläre Spielzeit")
$btnAnpfiffPause = GUICtrlCreateButton("Anpfiff 1. Halbzeit", 10, 220, 380, 50, 0x1) ; 0x1 = $BS_DEFPUSHBUTTON
GUICtrlSetFont(-1, 20, 600)
$chkTool = GUICtrlCreateCheckbox("mm:ss als Tooltip", 10, 280, 180, 20)
GUICtrlCreateLabel("(c) by Prog@ndy 2009", 190, 280, 200, 20,$SS_RIGHT)
GUISetState()


Global $TimerValue, $HalbZeit, $Status=0, $SpielCounter=0


While 1
Switch GUIGetMsg()
Case -3
Exit
Case $chkTool
ToolTip('')
Case $btnAnpfiffPause
Switch $Status
Case 0
$TimerValue = TimerInit()
AdlibRegister("_UpdateClock", 100)
$SpielCounter += 1
$HalbZeit=0
GUICtrlSetData($btnAnpfiffPause, "Halbzeitpfiff")
_LogEvent( "========== "&$SpielCounter&". SPIEL ==========")
_LogEvent( _NowTime() & ": Anpfiff 1. Halbzeit")
Case 1
AdlibUnRegister("_UpdateClock")
_LogEvent( _NowTime() & ": Halbzeit")
Local $Nachspielzeit = GUICtrlRead($lblNachspielzeit)
If $Nachspielzeit <> "00:00.00" Then _LogEvent("Nachspielzeit: " & $Nachspielzeit)
GUICtrlSetData($btnAnpfiffPause, "Anpfiff 2.Halbzeit")
Case 2
$TimerValue = TimerInit()
$HalbZeit = 45
GUICtrlSetData($lblNachspielzeit, '00:00.00')
AdlibRegister("_UpdateClock", 100)
_LogEvent(_NowTime() & ": Anpfiff 2.Halbzeit")
GUICtrlSetData($btnAnpfiffPause, "Abpfiff")
Case 3
AdlibUnRegister("_UpdateClock")
_LogEvent(_NowTime() & ": Spielende")
Local $Nachspielzeit = GUICtrlRead($lblNachspielzeit)
If $Nachspielzeit <> "00:00.00" Then _LogEvent("Nachspielzeit: " & $Nachspielzeit)
GUICtrlSetState($btnAnpfiffPause, $GUI_DISABLE)
Sleep(800)
GUICtrlSetData($btnAnpfiffPause, "NEU: Anpfiff 1. Halbzeit")
GUICtrlSetState($btnAnpfiffPause, $GUI_ENABLE)
$Status = -1
EndSwitch
$Status += 1
EndSwitch
WEnd
Func _LogEvent($sText)
_GUICtrlListBox_SetTopIndex($lstZeiten, _GUICtrlListBox_AddString($lstZeiten, $sText))
EndFunc
Func _UpdateClock()
Local $Val = TimerDiff($TimerValue) ; +2698000 ; Zum testen 44 Minuten und 50 Sekunden mehr
Local $hsecs = Floor(Mod($Val, 1000)/10)
$Val = Floor($Val/1000)
Local $secs = Mod($Val, 60)
$Val = Floor($Val/60)
If $Val >= 45 Then
GUICtrlSetData($lblUhr, (45+$HalbZeit) & ':00.00')
GUICtrlSetData($lblNachspielzeit, StringFormat("%02d:%02d.%02d", $Val-45, $secs, $hsecs))
GUICtrlSetData($lblGesamt, StringFormat("%02d:%02d.%02d", $Val+$HalbZeit, $secs, $hsecs))
Else
GUICtrlSetData($lblUhr, StringFormat("%02d:%02d.%02d", $Val+$HalbZeit, $secs, $hsecs))
EndIf
;If GUICtrlRead($chkTool)<>4 Then ToolTip(StringFormat("%02d:%02d", $Val+$HalbZeit, $secs), 1, 1, "Spielzeit")
If BitAND(GUICtrlRead($chkTool),$GUI_CHECKED) Then ToolTip(StringFormat("Spielzeit: %02d:%02d", $Val+$HalbZeit, $secs), 1, 1)
EndFunc
#ce




