Código: Seleccionar todo
#include <GUIConstantsEx.au3>
#include <EditConstants.au3>
#include <Date.au3>
Global $aMaquinas[12], $aTimer[12], $Secs, $Mins, $Hour, $bState[12], $aTime[12], $aTiempos[12]
Example()
Func Example()
Opt("GUIOnEventMode", 1)
GUICreate("Control Cyber", 800, 270)
GUISetBkColor(0x0093FF)
GUISetOnEvent($GUI_EVENT_CLOSE, "SpecialEvents")
GUISetOnEvent($GUI_EVENT_MINIMIZE, "SpecialEvents")
GUISetOnEvent($GUI_EVENT_RESTORE, "SpecialEvents")
Load()
For $i = 0 To 5
GUICtrlCreateGroup("MAQUINA_" & $i + 1, 10 + ($i * 130), 5, 130, 110)
GUICtrlSetFont(-1, 10, 700, 2, "Arial")
GUICtrlSetBkColor(-1, 0xfffffff)
$aMaquinas[$i] = GUICtrlCreateInput($aTiempos[$i], 15 + ($i * 130), 20, 120, 40, $ES_READONLY)
GUICtrlSetFont(-1, 22, 600, 0, "Bodoni MT")
GUICtrlSetBkColor(-1, 0xEA1515)
GUICtrlCreateButton("Comenzar", 15 + ($i * 130), 70, 120, 40)
GUICtrlSetFont(-1, 16, 400, 0, "Arial")
GUICtrlSetOnEvent(-1, "MaquinaEvent")
Next
For $i = 0 To 5
GUICtrlCreateGroup("MAQUINA_" & $i + 7, 10 + ($i * 130), 130, 130, 110)
GUICtrlSetFont(-1, 10, 700, 2, "Arial")
GUICtrlSetBkColor(-1, 0xfffffff)
$aMaquinas[$i + 6] = GUICtrlCreateInput($aTiempos[$i + 6], 15 + ($i * 130), 145, 120, 40, $ES_READONLY)
GUICtrlSetFont(-1, 22, 600, 0, "Bodoni MT")
GUICtrlSetBkColor(-1, 0xEA1515)
GUICtrlCreateButton("Comenzar", 15 + ($i * 130), 195, 120, 40)
GUICtrlSetFont(-1, 16, 400, 0, "Arial") ;
GUICtrlSetOnEvent(-1, "MaquinaEvent")
Next
GUISetState(@SW_SHOW)
AdlibRegister("Save", 1000)
AdlibRegister("Tiempo", 50)
While 1
Sleep(30)
WEnd
EndFunc ;==>Example
Func Load()
For $i = 1 To 12
$aTiempos[$i - 1] = IniRead("tiempos.ini", "Tiempos", "MAQUINA_" & $i, "00:00:00")
Next
EndFunc ;==>Load
Func Save()
For $i = 1 To 12
If $bState[$i - 1] Then
IniWrite("Tiempos.ini", "Tiempos", "MAQUINA_" & $i, GUICtrlRead($aMaquinas[$i - 1]))
Else
IniWrite("Tiempos.ini", "Tiempos", "MAQUINA_" & $i, "00:00:00")
EndIf
Next
EndFunc ;==>Save
Func Tiempo()
Local $asTime[12]
Local $asTime=0
For $i = 0 To 11
If $bState[$i] Then
_TicksToTime(Int(TimerDiff($aTimer[$i])), $Hour, $Mins, $Secs)
$asTime = $aTime[$i]
$aTime[$i] = StringFormat("%02i:%02i:%02i", $Hour, $Mins, $Secs)
If $asTime <> $aTime[$i] Then GUICtrlSetData($aMaquinas[$i], $aTime[$i])
EndIf
Next
EndFunc ;==>Tiempo
Func MaquinaEvent()
Local $i = Int(@GUI_CtrlId / 3) - 1
If $bState[$i] Then
TimerDiff($aTimer[$i])
$bState[$i] = False
GUICtrlSetData(@GUI_CtrlId, "Comenzar")
GUICtrlSetBkColor(@GUI_CtrlId - 1, 0xEA1515)
Else
GUICtrlSetData(@GUI_CtrlId, "Pausar")
GUICtrlSetBkColor(@GUI_CtrlId - 1, 0x2DD25)
$bState[$i] = True
$aTimer[$i] = TimerInit()
EndIf
EndFunc ;==>MaquinaEvent
Func SpecialEvents()
Local $iMsg = 0
Select
Case @GUI_CtrlId = $GUI_EVENT_CLOSE
$iMsg = MsgBox(4, "Control Cyber", "¿Reaalmente quiere salir?")
If $iMsg = 6 Then
GUIDelete()
Exit
EndIf
Case @GUI_CtrlId = $GUI_EVENT_MINIMIZE
Case @GUI_CtrlId = $GUI_EVENT_RESTORE
EndSelect
EndFunc ;==>SpecialEvents
Saludos