PS: das letzte Input feld unten wenn dort was drin steht läuft er nur noch und Stopt nicht wenn die zeit abgelaufen ist (Aufnaheme 5)
Ja, die Abfrage in _StopTimer war nicht korrekt.
AutoIt
#include <GUIConstantsEx.au3>
Global Const $sWinOBS = "OBS 26.1.1 (64-bit, windows) - Profil: Unbenannt - Szenen: Unbenannt"
Global $bIdle = True ; True = Leerlauf, keine Aufnahme läuft
Global $TimerStart ; wird gesetzt wenn eine Aufnahme beginnt
Global $aRecTimes[5] ; die eingetragenen Aufnahmezeiten in Sekunden
Global $aCheckbox[4] ; Array mit Checkbox-ID
Global $iCurrRec = -1 ; Index der aktuellen Aufnahme, bei Programmstart: keiner
Global $aGroupTitle[] = ['Stunden','Minuten','Sekunden']
Global $aInput[5][3]
Global $button[2]=['Start','Stop']
Global $hGui = GUICreate('5 Aufnahme-Timer', 800, 700, Default, Default, 0x10C80000)
For $i=0 To 2
GUICtrlCreateGroup($aGroupTitle[$i], 5+70*$i, 5, 70, 40)
For $j = 0 To 4
If $j > 0 Then GUICtrlCreateGroup('', 5+70*$i, 5+$j*30, 70, 40)
$aInput[$j][$i] = GUICtrlCreateInput('', 10+70*$i, 20+30*$j, 60, 20, 1)
Next
Next
$go = GUICtrlCreateButton('Start', 550, 650, 210, 20)
$Herunterfahren = GUICtrlCreateCheckbox("Computer herunterfahren", 600, 600, 201, 25)
For $i = 0 To 3
$aCheckbox[$i] = GUICtrlCreateCheckbox("Aufnahme " & $i+2 & " Aktivieren", 220, 47+$i*30, 201, 25)
Next
$Close = GUICtrlCreateButton("Schließen", 550, 550, 83, 25)
$Label2 = GUICtrlCreateLabel("Programm Start mit Hotkey F7", 500, 500, 170, 24)
GUICtrlSetFont(-1, 6, 800, 0, "MS Sans Serif")
GUISetState()
; MainLoop
While True
Switch GUIGetMsg()
Case -3
Exit
Case $go
If $bIdle Then
StartTimer()
Else
StopTimer() ; zum Abbruch einer laufenden Aufnahme
EndIf
EndSwitch
If Not $bIdle Then
If _CheckTimer() Then StopTimer()
EndIf
WEnd
Func _CalcRecordingSeconds()
Local $inHr, $inMin, $inSec, $sumSec = 0
For $i = 0 To 4
$sumSec = 0
If $i > 0 Then
If BitAND(GUICtrlRead($aCheckbox[$i-1]), $GUI_UNCHECKED) Then ContinueLoop
EndIf
$inHr = GUICtrlRead($aInput[$i][0])
$inMin = GUICtrlRead($aInput[$i][1])
$inSec = GUICtrlRead($aInput[$i][2])
If $inHr <> '' Then $sumSec += $inHr*60*60
If $inMin <> '' Then $sumSec += $inMin*60
If $inSec <> '' Then $sumSec += $inSec
$aRecTimes[$i] = $sumSec
Next
EndFunc
HotKeySet ("{F7}", '_ToggleStartStop')
Func _ToggleStartStop()
Return ($bIdle ? StartTimer() : StopTimer())
EndFunc
Func StartTimer()
If $iCurrRec = -1 Then ; erstmaliger Aufruf
_CalcRecordingSeconds()
EndIf
While $iCurrRec < UBound($aRecTimes) -1
$iCurrRec += 1
If $aRecTimes[$iCurrRec] <> 0 Then ExitLoop ; leere Einträge überspringen
WEnd
If $aRecTimes[$iCurrRec] = 0 Then Return MsgBox(16, 'FEHLER', 'Keine Aufnahmezeiten eingetragen!')
MsgBox(64, 'Aufnahme', 'Starte Aufnahme #' & $iCurrRec+1)
GUICtrlSetData($go, 'Stop')
$TimerStart = TimerInit()
$bIdle = False
; starte Aufnahme
ControlSend($sWinOBS, "", "", "{F8}")
EndFunc
Func _CheckTimer()
Return (Floor(TimerDiff($TimerStart)/1000) >= $aRecTimes[$iCurrRec])
EndFunc
Func StopTimer()
$bIdle = True
; beende Aufnahme
ControlSend($sWinOBS, "", "", "{F8}")
MsgBox(64, 'Aufnahme', 'Stoppe Aufnahme #' & $iCurrRec+1)
GUICtrlSetData($go, 'Start')
If $iCurrRec = UBound($aRecTimes) -1 Then ; letzte Aufnahme beendet
If BitAND(GUICtrlRead($Herunterfahren), $GUI_CHECKED) Then
Return MsgBox(64, 'Herunterfahren', 'Hier [#' & @ScriptLineNumber & '] Shutdown einfügen.')
EndIf
EndIf
EndFunc
Alles anzeigen
