- Offizieller Beitrag
Ich habe Dir mal schnell einen Countdown-Timer geschrieben, den Du sicherlich leichter verstehst:
Spoiler anzeigen
#include <GUIConstantsEx.au3>
$iCounterStart = 100 ; in Sekunden
GUICreate('Countdown-Timer', 600, 100)
$progressbar = GUICtrlCreateProgress(10, 10, 580, 20)
GUICtrlSetData($progressbar, 100)
$label = GUICtrlCreateLabel($iCounterStart & ' sek.', 20, 40, 60, 20)
$button = GUICtrlCreateButton('Start', 75, 70, 70, 20)
GUISetState()
$iCounter = $iCounterStart
$bStartStop = False
$iOldValue = @SEC
Do
$msg = GUIGetMsg()
If $msg = $button Then
$bStartStop = Not $bStartStop
Switch $bStartStop
Case True
GUICtrlSetData($button, 'Pause')
Case False
GUICtrlSetData($button, 'Weiter')
EndSwitch
EndIf
If $bStartStop Then
If $iOldValue <> @SEC Then
$iOldValue = @SEC
$iCounter -= 1
GUICtrlSetData($progressbar, Int(100/$iCounterStart*$iCounter))
GUICtrlSetData($label, $iCounter & ' sek.')
EndIf
Else
$iOldValue = @SEC
EndIf
If $iCounter < 1 Then
MsgBox(0, 0, 'Zeit um!')
ExitLoop
EndIf
Until $msg = $GUI_EVENT_CLOSE