Hallo Zusammen,
Ich bin leider noch nicht so erfahren mit AutoIT und habe versucht einen Timer zu "basteln".
Ich habe ein gutes Beispiel gefunden und es für mich angepasst. Funktionierte soweit ganz gut.
Ich brauche aber mindestens 2 Timer, die ablaufen.
Meine Frage nun:
Kann man auch 2 Timer gleichzeitig ablaufen lassen?
Ich habe es mir mal einfach gemacht und mein Script kopiert. Die Variablen habe ich natürlich
angepasst. Aber leider hat es damit nicht funktioniert. Es läuft immer nur der zweite ab.
Vielleicht Könnt Ihr mir helfen.
Danke.
Klaus
Spoiler anzeigen
#include
#include
#include
#include
#include
#include
Global Const $hGUI = GUICreate("Timer", 720, 300)
GUISetBkColor(0xA6CAF0)
GuiCtrlCreateGroup("Timer", 4, 4, 480, 150)
[/autoit] [autoit][/autoit] [autoit]Global Const $idLableStd = GUICtrlCreateLabel("Std", 10, 18, 40, 20)
GUICtrlSetFont(-1, 10, 10, 0, "Times New Roman")
Global $idInputStd = GUICtrlCreateInput("1", 8, 35, 40, 20, BitOR($ES_CENTER,$ES_NUMBER))
GUICtrlSetFont(-1, 10, 10, 0, "Times New Roman")
Global Const $idUpdownStd = GUICtrlCreateUpdown($idInputStd)
GUICtrlSetLimit(-1, 999, 0)
Global Const $idLableDP1 = GUICtrlCreateLabel(":", 58, 35, 40, 20)
GUICtrlSetFont(-1, 10, 10, 0, "Times New Roman")
Global Const $idLableMin = GUICtrlCreateLabel("Min", 70, 18, 40, 20)
GUICtrlSetFont(-1, 10, 10, 0, "Times New Roman")
Global $idInputMin = GUICtrlCreateInput("0", 68, 35, 40, 20, BitOR($ES_CENTER,$ES_NUMBER))
GUICtrlSetFont(-1, 10, 10, 0, "Times New Roman")
Global Const $idUpdownMin = GUICtrlCreateUpdown($idInputMin)
GUICtrlSetLimit(-1, 59, 0)
Global Const $idLableDP2 = GUICtrlCreateLabel(":", 118, 35, 40, 20)
GUICtrlSetFont(-1, 10, 10, 0, "Times New Roman")
Global Const $idLableSec = GUICtrlCreateLabel("Sec", 130, 18, 40, 20)
GUICtrlSetFont(-1, 10, 10, 0, "Times New Roman")
Global $idInputSek = GUICtrlCreateInput("0", 128, 35, 40, 20, BitOR($ES_CENTER,$ES_NUMBER))
GUICtrlSetFont(-1, 10, 10, 0, "Times New Roman")
Global Const $idUpdownSek = GUICtrlCreateUpdown($idInputSek)
GUICtrlSetLimit(-1, 59, 0)
; 2 Timer
Global $idInputStd1 = GUICtrlCreateInput("1", 8, 65, 40, 20, BitOR($ES_CENTER,$ES_NUMBER))
GUICtrlSetFont(-1, 10, 10, 0, "Times New Roman")
Global Const $idUpdownStd1 = GUICtrlCreateUpdown($idInputStd1)
GUICtrlSetLimit(-1, 999, 0)
Global Const $idLableDP11 = GUICtrlCreateLabel(":", 58, 65, 40, 20)
GUICtrlSetFont(-1, 10, 10, 0, "Times New Roman")
Global $idInputMin1 = GUICtrlCreateInput("0", 68, 65, 40, 20, BitOR($ES_CENTER,$ES_NUMBER))
GUICtrlSetFont(-1, 10, 10, 0, "Times New Roman")
Global Const $idUpdownMin1 = GUICtrlCreateUpdown($idInputMin1)
GUICtrlSetLimit(-1, 59, 0)
Global Const $idLableDP21 = GUICtrlCreateLabel(":", 118, 65, 40, 20)
GUICtrlSetFont(-1, 10, 10, 0, "Times New Roman")
Global $idInputSek1 = GUICtrlCreateInput("0", 128, 65, 40, 20, BitOR($ES_CENTER,$ES_NUMBER))
GUICtrlSetFont(-1, 10, 10, 0, "Times New Roman")
Global Const $idUpdownSek1 = GUICtrlCreateUpdown($idInputSek1)
GUICtrlSetLimit(-1, 59, 0)
Global Const $idButtonStart = GUICtrlCreateButton("Start", 178, 35, 40, 20)
GUICtrlSetFont(-1, 10, 10, 0, "Times New Roman")
Global Const $idButtonStop = GUICtrlCreateButton("Stop", 228, 35, 40, 20)
GUICtrlSetFont(-1, 10, 10, 0, "Times New Roman")
GUICtrlSetState(-1, $GUI_DISABLE)
Global Const $idButtonReset = GUICtrlCreateButton("Reset", 278, 35, 40, 20)
GUICtrlSetFont(-1, 10, 10, 0, "Times New Roman")
GUICtrlSetState(-1, $GUI_DISABLE)
;2 Timer
Global Const $idButtonStart1 = GUICtrlCreateButton("Start", 178, 65, 40, 20)
GUICtrlSetFont(-1, 10, 10, 0, "Times New Roman")
Global Const $idButtonStop1 = GUICtrlCreateButton("Stop", 228, 65, 40, 20)
GUICtrlSetFont(-1, 10, 10, 0, "Times New Roman")
GUICtrlSetState(-1, $GUI_DISABLE)
Global Const $idButtonReset1 = GUICtrlCreateButton("Reset", 278, 65, 40, 20)
GUICtrlSetFont(-1, 10, 10, 0, "Times New Roman")
GUICtrlSetState(-1, $GUI_DISABLE)
;Inputfelder
Global $idTicket = GUICtrlCreateInput("Ticket-ID", 338, 35, 120, 20)
GUICtrlSetFont(-1, 10, 10, 1, "Times New Roman")
Global $idTicket1 = GUICtrlCreateInput("Ticket-ID", 338, 65, 120, 20)
GUICtrlSetFont(-1, 10, 10, 1, "Times New Roman")
GUISetState(@SW_SHOW)
[/autoit] [autoit][/autoit] [autoit]ControlFocus("", "", $idButtonStart)
[/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]Global $nMsg, $seconds, $seconds2
[/autoit] [autoit][/autoit] [autoit]While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $idButtonStart
$seconds = GUICtrlRead($idInputStd) * 60^2 + GUICtrlRead($idInputMin) * 60 + GUICtrlRead($idInputSek) - 1
If $seconds > 0 Then
GUICtrlSetState($idButtonStart, $GUI_DISABLE)
GUICtrlSetState($idButtonStart, $GUI_DISABLE)
GUICtrlSetState($idUpdownStd, $GUI_DISABLE)
GUICtrlSetState($idUpdownMin, $GUI_DISABLE)
GUICtrlSetState($idUpdownSek, $GUI_DISABLE)
GUICtrlSetState($idButtonStop, $GUI_ENABLE)
AdlibRegister("Countdown1", 1000)
EndIf
Case $idButtonStart1 ; 2 Reihe
$seconds1 = GUICtrlRead($idInputStd1) * 60^2 + GUICtrlRead($idInputMin1) * 60 + GUICtrlRead($idInputSek1) - 1
If $seconds1 > 0 Then
GUICtrlSetState($idButtonStart1, $GUI_DISABLE)
GUICtrlSetState($idButtonStart1, $GUI_DISABLE)
GUICtrlSetState($idUpdownStd1, $GUI_DISABLE)
GUICtrlSetState($idUpdownMin1, $GUI_DISABLE)
GUICtrlSetState($idUpdownSek1, $GUI_DISABLE)
GUICtrlSetState($idButtonStop1, $GUI_ENABLE)
AdlibRegister("Countdown2", 1000)
EndIf
Case $idButtonStop
AdlibUnRegister("Countdown1")
GUICtrlSetState($idButtonStart, $GUI_ENABLE)
GUICtrlSetState($idButtonReset, $GUI_ENABLE)
GUICtrlSetState($idUpdownStd, $GUI_ENABLE)
GUICtrlSetState($idUpdownMin, $GUI_ENABLE)
GUICtrlSetState($idUpdownSek, $GUI_ENABLE)
GUICtrlSetState($idButtonStop, $GUI_DISABLE)
Case $idButtonStop1 ;2 Timer
AdlibUnRegister("Countdown2")
GUICtrlSetState($idButtonStart1, $GUI_ENABLE)
GUICtrlSetState($idButtonReset1, $GUI_ENABLE)
GUICtrlSetState($idUpdownStd1, $GUI_ENABLE)
GUICtrlSetState($idUpdownMin1, $GUI_ENABLE)
GUICtrlSetState($idUpdownSek1, $GUI_ENABLE)
GUICtrlSetState($idButtonStop1, $GUI_DISABLE)
Case $idButtonReset
GUICtrlSetData($idInputStd,1)
GUICtrlSetData($idInputMin,0)
GUICtrlSetData($idInputSek,0)
Case $idButtonReset1 ; 2 Timer
GUICtrlSetData($idInputStd1,1)
GUICtrlSetData($idInputMin1,0)
GUICtrlSetData($idInputSek1,0)
EndSwitch
WEnd
Func Countdown1()
Local $sec, $min, $hr
$sec = Mod($seconds, 60)
$min = Mod($seconds / 60, 60)
$hr = Floor($seconds / 60 ^ 2)
GUICtrlSetData($idInputStd1, StringFormat("i", $hr))
GUICtrlSetData($idInputMin1, StringFormat("i", $min))
GUICtrlSetData($idInputSek1, StringFormat("i", $sec))
If $seconds <= 0 Then
AdlibUnRegister("Countdown1")
$Ticket = GUICtrlRead($idTicket)
MsgBox(0, "Timer", "Für das Ticket "&$Ticket&" muß eine Mail verschickt werden")
;Exit
EndIf
$seconds -= 1
EndFunc
Func Countdown2()
Local $sec1, $min1, $hr1
$sec1 = Mod($seconds1, 60)
$min1 = Mod($seconds1 / 60, 60)
$hr1 = Floor($seconds1 / 60 ^ 2)
GUICtrlSetData($idInputStd1, StringFormat("i", $hr1))
GUICtrlSetData($idInputMin1, StringFormat("i", $min1))
GUICtrlSetData($idInputSek1, StringFormat("i", $sec1))
If $seconds1 <= 0 Then
AdlibUnRegister("Countdown2")
$Ticket1 = GUICtrlRead($idTicket1)
MsgBox(0, "Timer2", "Für das Ticket "&$Ticket1&" muß eine Mail verschickt werden")
;Exit
EndIf
$seconds1 -= 1
EndFunc