Jump to content

Multiple timers


Snarg
 Share

Recommended Posts

Greetings. I am trying to create a simple GUI that uses multiple timers. Making the GUI is no problem however getting output from two seperate timers in two seperate controls is killing me. I can get one timer to start however when I attempt to start the second timer the first one stops. Any help would be greatly appreciated. Following is the code I have so far:

#include <GUIConstants.au3>
#include <Date.au3>

GuiCreate("MyGUI", 392, 323)

$Button_1 = GuiCtrlCreateButton("Start", 10, 50, 50, 20)
$Button_2 = GuiCtrlCreateButton("Stop", 60, 50, 50, 20)
$Input_3 = GuiCtrlCreateInput("", 10, 70, 100, 20, 0x1000)
$Label_4 = GuiCtrlCreateLabel("", 10, 10, 100, 30, 0x1000)
$Button_5 = GuiCtrlCreateButton("Start", 130, 50, 50, 20)
$Button_6 = GuiCtrlCreateButton("Stop", 180, 50, 50, 20)
$Input_7 = GuiCtrlCreateInput("", 130, 70, 100, 20, 0x1000)
$Label_8 = GuiCtrlCreateLabel("", 130, 10, 100, 30, 0x1000)

GUISetState()

While 1
    $msg = GUIGetMsg()
        Select
        Case $msg = $Button_1
                $timer1 = TimerInit()
                AdlibEnable("Timer1", 50)
            Case $msg = $Button_2
                $Lable_4 = GUICtrlCreateLabel("00:00:00", 10, 10, 100, 30, 0x1000)
                AdlibDisable()
            Case $msg = $Button_5
                $timer2 = TimerInit()
                AdlibEnable("Timer2", 50)
            Case $msg = $Button_6
                $Lable_8 = GUICtrlCreateLabel("00:00:00", 130, 10, 100, 30, 0x1000)
                AdlibDisable()
            Case $msg = $GUI_EVENT_CLOSE
        EndSelect
    If $msg = $GUI_EVENT_CLOSE Then ExitLoop
Wend

Func Timer1()
    Local $Secs, $Mins, $Hour, $Time1, $sTime = $Time1
    _TicksToTime(Int(TimerDiff($timer1)), $Hour, $Mins, $Secs )
    $Time1 = StringFormat("%02i:%02i:%02i", $Hour, $Mins, $Secs)
    If $sTime <> $Time1 Then ControlSetText("MyGUI", "", "Static1", $Time1)
EndFunc
    
Func Timer2()
    Local $Secs, $Mins, $Hour, $Time2, $sTime = $Time2
    _TicksToTime(Int(TimerDiff($timer2)), $Hour, $Mins, $Secs )
    $Time2 = StringFormat("%02i:%02i:%02i", $Hour, $Mins, $Secs)
    If $sTime <> $Time2 Then ControlSetText("MyGUI", "", "Static2", $Time2)
EndFunc

A little reading goes a long way. Post count means nothing.

Link to comment
Share on other sites

Burrup is right. Only one Adlib function can be active at a time, which explains why one counter stops when you start the other.

Also, your labels are: $Label_4 and $Label_8, but you're also creating new ones ($Lable_4/$Lable_8) in the $msg loop.

Besides the spelling error, it is a bad practice to create controls in a loop without cleanup.

Click a stop button enough times and you'll bog down your system or crash the script.

It would be better to change the data in the existing controls.

Is this what you were trying to accomplish?

#include <GUIConstants.au3>
#include <Date.au3>

Dim $Timer1Active = 0
Dim $Timer2Active = 0
AdlibEnable("AllTimers", 500)

GUICreate("MyGUI", 392, 323)

$Button_1 = GUICtrlCreateButton("Start", 10, 50, 50, 20)
$Button_2 = GUICtrlCreateButton("Stop", 60, 50, 50, 20)
$Input_3 = GUICtrlCreateInput("", 10, 70, 100, 20, 0x1000)
$Label_4 = GUICtrlCreateLabel("", 10, 10, 100, 30, 0x1000)
$Button_5 = GUICtrlCreateButton("Start", 130, 50, 50, 20)
$Button_6 = GUICtrlCreateButton("Stop", 180, 50, 50, 20)
$Input_7 = GUICtrlCreateInput("", 130, 70, 100, 20, 0x1000)
$Label_8 = GUICtrlCreateLabel("", 130, 10, 100, 30, 0x1000)

GUISetState()

While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $Button_1
            $Timer1Active = 1
            $timer1 = TimerInit()
        Case $msg = $Button_2
            $Timer1Active = 0
            GUICtrlSetData($Label_4, "00:00:00")
;~           $Lable_4 = GUICtrlCreateLabel("00:00:00", 10, 10, 100, 30, 0x1000)
        Case $msg = $Button_5
            $Timer2Active = 1
            $timer2 = TimerInit()
        Case $msg = $Button_6
            $Timer2Active = 0
            GUICtrlSetData($Label_8, "00:00:00")
;~           $Lable_8 = GUICtrlCreateLabel("00:00:00", 130, 10, 100, 30, 0x1000)
        Case $msg = $GUI_EVENT_CLOSE
    EndSelect
    If $msg = $GUI_EVENT_CLOSE Then ExitLoop
WEnd

Func AllTimers()
    Local $Secs, $Mins, $Hour, $Time1, $Time2, $sTime1 = $Time1, $sTime2 = $Time2
    If $Timer1Active Then
        _TicksToTime(Int(TimerDiff($timer1)), $Hour, $Mins, $Secs)
        $Time1 = StringFormat("%02i:%02i:%02i", $Hour, $Mins, $Secs)
        If $sTime1 <> $Time1 Then ControlSetText("MyGUI", "", "Static1", $Time1)
    EndIf
    If $Timer2Active Then
        _TicksToTime(Int(TimerDiff($timer2)), $Hour, $Mins, $Secs)
        $Time2 = StringFormat("%02i:%02i:%02i", $Hour, $Mins, $Secs)
        If $sTime2 <> $Time2 Then ControlSetText("MyGUI", "", "Static2", $Time2)
    EndIf
EndFunc  ;==>AllTimers

[font="Tahoma"]"Tougher than the toughies and smarter than the smarties"[/font]

Link to comment
Share on other sites

Thank you for your help. I have managed to get it working. As you can see, it runs quite a few timers. I appologize for my ugly coding, I don't do this very often. Also, I am afraid this is not very efficient. Any help or suggestions would be greatly appreciated.

Eventualy I will have to add more timers. Does anyone know of a way to open an existing GUI in the GUI editor included, or is there some other GUI editor someone would like to recomend?

Thank you for your time.

Cafe_Log.au3

A little reading goes a long way. Post count means nothing.

Link to comment
Share on other sites

Thank you for your help. I have managed to get it working. As you can see, it runs quite a few timers. I appologize for my ugly coding, I don't do this very often. Also, I am afraid this is not very efficient. Any help or suggestions would be greatly appreciated.

Eventualy I will have to add more timers. Does anyone know of a way to open an existing GUI in the GUI editor included, or is there some other GUI editor someone would like to recomend?

Thank you for your time.

Same script - shorter - better

#include <GUIConstants.au3>
#include <Date.au3>

Dim $Header_1 = "Computer"
Dim $Header_2 = "Phone"
Dim $Header_3 = "PC"
Dim $Name, $TotalTime, $Unit, $count = 33
Dim $TimerActive_[50], $Label_[50], $TButton_[50], $SButton_[50], $Input_[50], $Label_[50]
Dim $Time_[50], $Timer_[50], $sTime_[50], $xk, $ck

$Log = FileOpen ("logfile.txt", 1)
FileWriteLine ($Log, "Logfile started: " & _DateTimeFormat( _NowCalc(),0) & @CRLF &  @CRLF)
FileClose ($Log)

AdlibEnable("AllTimers", 500)

GuiCreate("Net Cafe' Log by TSgt Farrell", 981, 470)

;Top computer label
GuiCtrlCreateLabel( $Header_1 & "s", 0, 0, 980, 20, $SS_CENTER, $WS_EX_STATICEDGE)
GUICtrlSetFont( -1, 12, 700)
GUICtrlSetColor( -1, 0xFFFFFF)
GUICtrlSetBkColor( -1, 999999)

;Input 1
$TButton_[1] = GuiCtrlCreateButton("Start", 0, 70, 50, 20)
$SButton_[1] = GuiCtrlCreateButton("Stop", 50, 70, 50, 20)
$Input_[1] = GuiCtrlCreateInput("", 0, 90, 100, 20, 0x1000)
$Label_[1] = GuiCtrlCreateLabel("", 0, 40, 100, 30, 0x1000)
GUICtrlSetFont ( -1, 16)
GUICtrlSetData($Label_[1], "00:00:00")
GuiCtrlCreateLabel($Header_1 & " 1", 0, 20, 100, 20, $SS_CENTER)
;Input 2
$TButton_[2] = GuiCtrlCreateButton("Start", 110, 70, 50, 20)
$SButton_[2] = GuiCtrlCreateButton("Stop", 160, 70, 50, 20)
$Input_[2] = GuiCtrlCreateInput("", 110, 90, 100, 20, 0x1000)
$Label_[2] = GuiCtrlCreateLabel("", 110, 40, 100, 30, 0x1000)
GUICtrlSetFont ( -1, 16)
GUICtrlSetData($Label_[2], "00:00:00")
GuiCtrlCreateLabel($Header_1 & " 2", 110, 20, 100, 20, $SS_CENTER)
;Input 3
$TButton_[3] = GuiCtrlCreateButton("Start", 220, 70, 50, 20)
$SButton_[3] = GuiCtrlCreateButton("Stop", 270, 70, 50, 20)
$Input_[3] = GuiCtrlCreateInput("", 220, 90, 100, 20, 0x1000)
$Label_[3] = GuiCtrlCreateLabel("", 220, 40, 100, 30, 0x1000)
GUICtrlSetFont ( -1, 16)
GUICtrlSetData($Label_[3], "00:00:00")
GuiCtrlCreateLabel($Header_1 & " 3", 220, 20, 100, 20, $SS_CENTER)
;Input 4
$TButton_[4] = GuiCtrlCreateButton("Start", 330, 70, 50, 20)
$SButton_[4] = GuiCtrlCreateButton("Stop", 380, 70, 50, 20)
$Input_[4] = GuiCtrlCreateInput("", 330, 90, 100, 20, 0x1000)
$Label_[4] = GuiCtrlCreateLabel("", 330, 40, 100, 30, 0x1000)
GUICtrlSetFont ( -1, 16)
GUICtrlSetData($Label_[4], "00:00:00")
GuiCtrlCreateLabel($Header_1 & " 4", 330, 20, 100, 20, $SS_CENTER)
;Input 5
$TButton_[5] = GuiCtrlCreateButton("Start", 440, 70, 50, 20)
$SButton_[5] = GuiCtrlCreateButton("Stop", 490, 70, 50, 20)
$Input_[5] = GuiCtrlCreateInput("", 440, 90, 100, 20, 0x1000)
$Label_[5] = GuiCtrlCreateLabel("", 440, 40, 100, 30, 0x1000)
GUICtrlSetFont ( -1, 16)
GUICtrlSetData($Label_[5], "00:00:00")
GuiCtrlCreateLabel($Header_1 & " 5", 440, 20, 100, 20, $SS_CENTER)
;Input 6
$TButton_[6] = GuiCtrlCreateButton("Start", 550, 70, 50, 20)
$SButton_[6] = GuiCtrlCreateButton("Stop", 600, 70, 50, 20)
$Input_[6] = GuiCtrlCreateInput("", 550, 90, 100, 20, 0x1000)
$Label_[6] = GuiCtrlCreateLabel("", 550, 40, 100, 30, 0x1000)
GUICtrlSetFont ( -1, 16)
GUICtrlSetData($Label_[6], "00:00:00")
GuiCtrlCreateLabel($Header_1 & " 6", 550, 20, 100, 20, $SS_CENTER)
;Input 7
$TButton_[7] = GuiCtrlCreateButton("Start", 660, 70, 50, 20)
$SButton_[7]= GuiCtrlCreateButton("Stop", 710, 70, 50, 20)
$Input_[7] = GuiCtrlCreateInput("", 660, 90, 100, 20, 0x1000)
$Label_[7] = GuiCtrlCreateLabel("", 660, 40, 100, 30, 0x1000)
GUICtrlSetFont ( -1, 16)
GUICtrlSetData($Label_[7], "00:00:00")
GuiCtrlCreateLabel($Header_1 & " 7", 660, 20, 100, 20, $SS_CENTER)
;Input 8
$TButton_[8] = GuiCtrlCreateButton("Start", 770, 70, 50, 20)
$SButton_[8] = GuiCtrlCreateButton("Stop", 820, 70, 50, 20)
$Input_[8] = GuiCtrlCreateInput("", 770, 90, 100, 20, 0x1000)
$Label_[8] = GuiCtrlCreateLabel("", 770, 40, 100, 30, 0x1000)
GUICtrlSetFont (-1, 16)
GUICtrlSetData($Label_[8], "00:00:00")
GuiCtrlCreateLabel($Header_1 & " 8", 770, 20, 100, 20, $SS_CENTER)
;Input 9
$TButton_[9] = GuiCtrlCreateButton("Start", 880, 70, 50, 20)
$SButton_[9]= GuiCtrlCreateButton("Stop", 930, 70, 50, 20)
$Input_[9] = GuiCtrlCreateInput("", 880, 90, 100, 20, 0x1000)
$Label_[9] = GuiCtrlCreateLabel("", 880, 40, 100, 30, 0x1000)
GUICtrlSetFont ( -1, 16)
GUICtrlSetData($Label_[9], "00:00:00")
GuiCtrlCreateLabel($Header_1 & " 9", 880, 20, 100, 20, $SS_CENTER)
;Input 10
$TButton_[10] = GuiCtrlCreateButton("Start", 0, 170, 50, 20)
$SButton_[10] = GuiCtrlCreateButton("Stop", 50, 170, 50, 20)
$Input_[10] = GuiCtrlCreateInput("", 0, 190, 100, 20, 0x1000)
$Label_[10] = GuiCtrlCreateLabel("", 0, 140, 100, 30, 0x1000)
GUICtrlSetFont ( -1, 16)
GUICtrlSetData($Label_[10], "00:00:00")
GuiCtrlCreateLabel($Header_1 & " 10", 0, 120, 100, 20, $SS_CENTER)
;Input 11
$TButton_[11] = GuiCtrlCreateButton("Start", 110, 170, 50, 20)
$SButton_[11] = GuiCtrlCreateButton("Stop", 160, 170, 50, 20)
$Input_[11] = GuiCtrlCreateInput("", 110, 190, 100, 20, 0x1000)
$Label_[11] = GuiCtrlCreateLabel("", 110, 140, 100, 30, 0x1000)
GUICtrlSetFont ( -1, 16)
GUICtrlSetData($Label_[11], "00:00:00")
GuiCtrlCreateLabel($Header_1 & " 11", 110, 120, 100, 20, $SS_CENTER)
;Input 12
$TButton_[12] = GuiCtrlCreateButton("Start", 220, 170, 50, 20)
$SButton_[12] = GuiCtrlCreateButton("Stop", 270, 170, 50, 20)
$Input_[12] = GuiCtrlCreateInput("", 220, 190, 100, 20, 0x1000)
$Label_[12] = GuiCtrlCreateLabel("", 220, 140, 100, 30, 0x1000)
GUICtrlSetFont ( -1, 16)
GUICtrlSetData($Label_[12], "00:00:00")
GuiCtrlCreateLabel($Header_1 & " 12", 220, 120, 100, 20, $SS_CENTER)
;Input 13
$TButton_[13] = GuiCtrlCreateButton("Start", 330, 170, 50, 20)
$SButton_[13] = GuiCtrlCreateButton("Stop", 380, 170, 50, 20)
$Input_[13] = GuiCtrlCreateInput("", 330, 190, 100, 20, 0x1000)
$Label_[13] = GuiCtrlCreateLabel("", 330, 140, 100, 30, 0x1000)
GUICtrlSetFont ( -1, 16)
GUICtrlSetData($Label_[13], "00:00:00")
GuiCtrlCreateLabel($Header_1 & " 13", 330, 120, 100, 20, $SS_CENTER)
;Input 14
$TButton_[14] = GuiCtrlCreateButton("Start", 440, 170, 50, 20)
$SButton_[14] = GuiCtrlCreateButton("Stop", 490, 170, 50, 20)
$Input_[14] = GuiCtrlCreateInput("", 440, 190, 100, 20, 0x1000)
$Label_[14] = GuiCtrlCreateLabel("", 440, 140, 100, 30, 0x1000)
GUICtrlSetFont ( -1, 16)
GUICtrlSetData($Label_[14], "00:00:00")
GuiCtrlCreateLabel($Header_1 & " 14", 440, 120, 100, 20, $SS_CENTER)
;Input 15
$TButton_[15] = GuiCtrlCreateButton("Start", 550, 170, 50, 20)
$SButton_[15] = GuiCtrlCreateButton("Stop", 600, 170, 50, 20)
$Input_[15] = GuiCtrlCreateInput("", 550, 190, 100, 20, 0x1000)
$Label_[15] = GuiCtrlCreateLabel("", 550, 140, 100, 30, 0x1000)
GUICtrlSetFont ( -1, 16)
GUICtrlSetData($Label_[15], "00:00:00")
GuiCtrlCreateLabel($Header_1 & " 15", 550, 120, 100, 20, $SS_CENTER)
;Input 16
$TButton_[16] = GuiCtrlCreateButton("Start", 660, 170, 50, 20)
$SButton_[16] = GuiCtrlCreateButton("Stop", 710, 170, 50, 20)
$Input_[16] = GuiCtrlCreateInput("", 660, 190, 100, 20, 0x1000)
$Label_[16] = GuiCtrlCreateLabel("", 660, 140, 100, 30, 0x1000)
GUICtrlSetFont ( -1, 16)
GUICtrlSetData($Label_[16], "00:00:00")
GuiCtrlCreateLabel($Header_1 & " 16", 660, 120, 100, 20, $SS_CENTER)
;Input 17
$TButton_[17] = GuiCtrlCreateButton("Start", 770, 170, 50, 20)
$SButton_[17] = GuiCtrlCreateButton("Stop", 820, 170, 50, 20)
$Input_[17] = GuiCtrlCreateInput("", 770, 190, 100, 20, 0x1000)
$Label_[17] = GuiCtrlCreateLabel("", 770, 140, 100, 30, 0x1000)
GUICtrlSetFont ( -1, 16)
GUICtrlSetData($Label_[17], "00:00:00")
GuiCtrlCreateLabel($Header_1 & " 17", 770, 120, 100, 20, $SS_CENTER)
;Input 18
$TButton_[18] = GuiCtrlCreateButton("Start", 880, 170, 50, 20)
$SButton_[18] = GuiCtrlCreateButton("Stop", 930, 170, 50, 20)
$Input_[18] = GuiCtrlCreateInput("", 880, 190, 100, 20, 0x1000)
$Label_[18] = GuiCtrlCreateLabel("", 880, 140, 100, 30, 0x1000)
GUICtrlSetFont ( -1, 16)
GUICtrlSetData($Label_[18], "00:00:00")
GuiCtrlCreateLabel($Header_1 & " 18", 880, 120, 100, 20, $SS_CENTER)

;Middle phones label
GuiCtrlCreateLabel($Header_2 & "s", 0, 220, 980, 20, $SS_CENTER, $WS_EX_STATICEDGE)
GUICtrlSetFont( -1, 12, 700)
GUICtrlSetColor( -1, 0xFFFFFF)
GUICtrlSetBkColor( -1, 999999)

;Input 19
$TButton_[19] = GuiCtrlCreateButton("Start", 0, 290, 50, 20)
$SButton_[19] = GuiCtrlCreateButton("Stop", 50, 290, 50, 20)
$Input_[19] = GuiCtrlCreateInput("", 0, 310, 100, 20, 0x1000)
$Label_[19] = GuiCtrlCreateLabel("", 0, 260, 100, 30, 0x1000)
GUICtrlSetFont ( -1, 16)
GUICtrlSetData($Label_[19], "00:00:00")
GuiCtrlCreateLabel($Header_2 & "  1", 0, 240, 100, 20, $SS_CENTER)
;Input 20
$TButton_[20] = GuiCtrlCreateButton("Start", 110, 290, 50, 20)
$SButton_[20] = GuiCtrlCreateButton("Stop", 160, 290, 50, 20)
$Input_[20] = GuiCtrlCreateInput("", 110, 310, 100, 20, 0x1000)
$Label_[20] = GuiCtrlCreateLabel("", 110, 260, 100, 30, 0x1000)
GUICtrlSetFont ( -1, 16)
GUICtrlSetData($Label_[20], "00:00:00")
GuiCtrlCreateLabel($Header_2 & "  2", 110, 240, 100, 20, $SS_CENTER)
;Input 21
$TButton_[21] = GuiCtrlCreateButton("Start", 220, 290, 50, 20)
$SButton_[21] = GuiCtrlCreateButton("Stop", 270, 290, 50, 20)
$Input_[21] = GuiCtrlCreateInput("", 220, 310, 100, 20, 0x1000)
$Label_[21] = GuiCtrlCreateLabel("", 220, 260, 100, 30, 0x1000)
GUICtrlSetFont ( -1, 16)
GUICtrlSetData($Label_[21], "00:00:00")
GuiCtrlCreateLabel($Header_2 & "  3", 220, 240, 100, 20, $SS_CENTER)
;Input 22
$TButton_[22] = GuiCtrlCreateButton("Start", 330, 290, 50, 20)
$SButton_[22] = GuiCtrlCreateButton("Stop", 380, 290, 50, 20)
$Input_[22] = GuiCtrlCreateInput("", 330, 310, 100, 20, 0x1000)
$Label_[22] = GuiCtrlCreateLabel("", 330, 260, 100, 30, 0x1000)
GUICtrlSetFont ( -1, 16)
GUICtrlSetData($Label_[22], "00:00:00")
GuiCtrlCreateLabel($Header_2 & "  4", 330, 240, 100, 20, $SS_CENTER)
;Input 23
$TButton_[23] = GuiCtrlCreateButton("Start", 440, 290, 50, 20)
$SButton_[23] = GuiCtrlCreateButton("Stop", 490, 290, 50, 20)
$Input_[23] = GuiCtrlCreateInput("", 440, 310, 100, 20, 0x1000)
$Label_[23] = GuiCtrlCreateLabel("", 440, 260, 100, 30, 0x1000)
GUICtrlSetFont ( -1, 16)
GUICtrlSetData($Label_[23], "00:00:00")
GuiCtrlCreateLabel($Header_2 & "  5", 440, 240, 100, 20, $SS_CENTER)
;Input 24
$TButton_[24] = GuiCtrlCreateButton("Start", 550, 290, 50, 20)
$SButton_[24] = GuiCtrlCreateButton("Stop", 600, 290, 50, 20)
$Input_[24] = GuiCtrlCreateInput("", 550, 310, 100, 20, 0x1000)
$Label_[24] = GuiCtrlCreateLabel("", 550, 260, 100, 30, 0x1000)
GUICtrlSetFont ( -1, 16)
GUICtrlSetData($Label_[24], "00:00:00")
GuiCtrlCreateLabel($Header_2 & "  6", 550, 240, 100, 20, $SS_CENTER)
;Input 25
$TButton_[25] = GuiCtrlCreateButton("Start", 660, 290, 50, 20)
$SButton_[25] = GuiCtrlCreateButton("Stop", 710, 290, 50, 20)
$Input_[25] = GuiCtrlCreateInput("", 660, 310, 100, 20, 0x1000)
$Label_[25] = GuiCtrlCreateLabel("", 660, 260, 100, 30, 0x1000)
GUICtrlSetFont ( -1, 16)
GUICtrlSetData($Label_[25], "00:00:00")
GuiCtrlCreateLabel($Header_2 & "  7", 660, 240, 100, 20, $SS_CENTER)
;Input 26
$TButton_[26] = GuiCtrlCreateButton("Start", 770, 290, 50, 20)
$SButton_[26] = GuiCtrlCreateButton("Stop", 820, 290, 50, 20)
$Input_[26] = GuiCtrlCreateInput("", 770, 310, 100, 20, 0x1000)
$Label_[26] = GuiCtrlCreateLabel("", 770, 260, 100, 30, 0x1000)
GUICtrlSetFont ( -1, 16)
GUICtrlSetData($Label_[26], "00:00:00")
GuiCtrlCreateLabel($Header_2 & "  8", 770, 240, 100, 20, $SS_CENTER)
;Input 27
$TButton_[27] = GuiCtrlCreateButton("Start", 880, 290, 50, 20)
$SButton_[27] = GuiCtrlCreateButton("Stop", 930, 290, 50, 20)
$Input_[27] = GuiCtrlCreateInput("", 880, 310, 100, 20, 0x1000)
$Label_[27] = GuiCtrlCreateLabel("", 880, 260, 100, 30, 0x1000)
GUICtrlSetFont ( -1, 16)
GUICtrlSetData($Label_[27], "00:00:00")
GuiCtrlCreateLabel($Header_2 & "  9", 880, 240, 100, 20, $SS_CENTER)

;Bottom PC label
GuiCtrlCreateLabel($Header_3 & "'s", 0, 340, 980, 20, $SS_CENTER, $WS_EX_STATICEDGE)
GUICtrlSetFont( -1, 12, 700)
GUICtrlSetColor( -1, 0xFFFFFF)
GUICtrlSetBkColor( -1, 999999)

;Input 28
$TButton_[28] = GuiCtrlCreateButton("Start", 0, 410, 50, 20)
$SButton_[28] = GuiCtrlCreateButton("Stop", 50, 410, 50, 20)
$Input_[28] = GuiCtrlCreateInput("", 0, 430, 100, 20, 0x1000)
$Label_[28] = GuiCtrlCreateLabel("", 0, 380, 100, 30, 0x1000)
GUICtrlSetFont ( -1, 16)
GUICtrlSetData($Label_[28], "00:00:00")
GuiCtrlCreateLabel($Header_3 & " 1", 0, 360, 100, 20, $SS_CENTER)
;Input 29
$TButton_[29] = GuiCtrlCreateButton("Start", 110, 410, 50, 20)
$SButton_[29] = GuiCtrlCreateButton("Stop", 160, 410, 50, 20)
$Input_[29] = GuiCtrlCreateInput("", 110, 430, 100, 20, 0x1000)
$Label_[29] = GuiCtrlCreateLabel("", 110, 380, 100, 30, 0x1000)
GUICtrlSetFont ( -1, 16)
GUICtrlSetData($Label_[29], "00:00:00")
GuiCtrlCreateLabel($Header_3 & " 2", 110, 360, 100, 20, $SS_CENTER)
;Input 30
$TButton_[30] = GuiCtrlCreateButton("Start", 220, 410, 50, 20)
$SButton_[30] = GuiCtrlCreateButton("Stop", 270, 410, 50, 20)
$Input_[30] = GuiCtrlCreateInput("", 220, 430, 100, 20, 0x1000)
$Label_[30] = GuiCtrlCreateLabel("", 220, 380, 100, 30, 0x1000)
GUICtrlSetFont ( -1, 16)
GUICtrlSetData($Label_[30], "00:00:00")
GuiCtrlCreateLabel($Header_3 & " 3", 220, 360, 100, 20, $SS_CENTER)
;Input 31
$TButton_[31] = GuiCtrlCreateButton("Start", 330, 410, 50, 20)
$SButton_[31] = GuiCtrlCreateButton("Stop", 380, 410, 50, 20)
$Input_[31] = GuiCtrlCreateInput("", 330, 430, 100, 20, 0x1000)
$Label_[31] = GuiCtrlCreateLabel("", 330, 380, 100, 30, 0x1000)
GUICtrlSetFont ( -1, 16)
GUICtrlSetData($Label_[31], "00:00:00")
GuiCtrlCreateLabel($Header_3 & " 4", 330, 360, 100, 20, $SS_CENTER)
;Input 32
$TButton_[32] = GuiCtrlCreateButton("Start", 440, 410, 50, 20)
$SButton_[32] = GuiCtrlCreateButton("Stop", 490, 410, 50, 20)
$Input_[32] = GuiCtrlCreateInput("", 440, 430, 100, 20, 0x1000)
$Label_[32] = GuiCtrlCreateLabel("", 440, 380, 100, 30, 0x1000)
GUICtrlSetFont ( -1, 16)
GUICtrlSetData($Label_[32], "00:00:00")
GuiCtrlCreateLabel($Header_3 & " 5", 440, 360, 100, 20, $SS_CENTER)
;Input 33
$TButton_[33] = GuiCtrlCreateButton("Start", 550, 410, 50, 20)
$SButton_[33] = GuiCtrlCreateButton("Stop", 600, 410, 50, 20)
$Input_[33] = GuiCtrlCreateInput("", 550, 430, 100, 20, 0x1000)
$Label_[33] = GuiCtrlCreateLabel("", 550, 380, 100, 30, 0x1000)
GUICtrlSetFont ( -1, 16)
GUICtrlSetData($Label_[33], "00:00:00")
GuiCtrlCreateLabel($Header_3 & " 6", 550, 360, 100, 20, $SS_CENTER)

GUISetState()

While 1
    $msg = GUIGetMsg()
    
    For $xk = 1 to $count
        If $msg = $TButton_[$xk] Then
            GUICtrlSetState($TButton_[$xk], $GUI_DISABLE)
            $TimerActive_[$xk] = 1
            $timer_[$xk] = TimerInit()
        EndIf
        If $msg = $SButton_[$xk] Then
            $TimerActive_[$xk] = 0
            GUICtrlSetState($TButton_[$xk], $GUI_ENABLE)
          ;GUICtrlSetData($Label_[$xk], "00:00:00")
            GUICtrlSetColor($Label_[$xk], 0x000000)
            $Name = GUICtrlRead ($Input_[$xk])
        ;GUICtrlSetData($Input_[$xk], "")
            If $xk < 19 Then
            $Unit = $Header_1 & "  " & $xk
            EndIf
            If $xk >= 19 And $xk < 28 Then
            $Unit = $Header_2 & "   " & $xk-18
            EndIf
            If $xk >= 28 Then
            $Unit = $Header_3 & "   " & $xk-27
            EndIf
            RecordStuff()
        EndIf
        If $xk = 33 Then ExitLoop
    Next
    If $msg = $GUI_EVENT_CLOSE Then ExitLoop
WEnd

Func AllTimers()
    Local $Secs, $Mins, $Hour
    For $ck = 1 to $count
        
        If $TimerActive_[$ck] Then
            _TicksToTime(Int(TimerDiff($timer_[$ck])), $Hour, $Mins, $Secs)
            $Time_[$ck] = StringFormat("%02i:%02i:%02i", $Hour, $Mins, $Secs)
            If $sTime_[$ck] <> $Time_[$ck] Then ControlSetText("Net Cafe' Log by TSgt Farrell", "", $Label_[$ck], $Time_[$ck])
            If $Mins > 30 Then GUICtrlSetColor($Label_[$ck], 0xff0000)
        EndIf
    Next
EndFunc

Func RecordStuff ()
    $LogStuff = FileOpen ("logfile.txt", 1)
    FileWriteLine ($LogStuff, "Station: " & $Unit & @CRLF)
    FileWriteLine ($LogStuff, "User name: " & (GUICtrlRead($Input_[$xk])) & @CRLF)
    FileWriteLine ($LogStuff, "Total time: " & (GUICtrlRead($Label_[$xk])) & @CRLF & @CRLF)
    FileClose ($LogStuff)
EndFunc

8)

Edited by Valuater

NEWHeader1.png

Link to comment
Share on other sites

@Valuater

your script doesn't start counting?

Or is it because I'm using the stable version of AutoIt and not beta?

@Snarg

I think it would be better if the timer would freeze the counter on pressing the stop button, then reset on pressing the start button again

The speed of sound is defined by the distance from door to computer divided by the time interval needed to close the media player and pull up your pants when your mom shouts "OH MY GOD WHAT ARE YOU DOING!!!"

Link to comment
Share on other sites

Even Better

makes a daily record of use

when started it...

needs a user

disables the start button

disables the input

When Stopped it...

Changes "Stop" to "Reset"

to allow viewing of use time

#include <GUIConstants.au3>
#include <Date.au3>

Dim $Header_1 = "Machine"
Dim $Header_2 = "Line"
Dim $Header_3 = "Office"
Dim $Name, $TotalTime, $Unit, $count = 33
Dim $TimerActive_[50], $Label_[50], $TButton_[50], $SButton_[50], $Input_[50], $Label_[50]
Dim $Time_[50], $Timer_[50], $sTime_[50], $xk, $ck

$Today_File = @MON & "-" & @MDAY & "-" & @YEAR & ".txt"
$Log = FileOpen ($Today_File, 1)
FileWriteLine ($Log, "Logfile started: " & _DateTimeFormat( _NowCalc(),0) & @CRLF &  @CRLF)
FileClose ($Log)

$Toy_Logo = @TempDir & "\Toy2-logo.jpg"
FileInstall("C:\XPClean-web\Settings\XPClean-pics\Toy-box2-jpg.jpg", $Toy_Logo)
$Toy_Banner = @TempDir & "\Toy-banr.jpg"
FileInstall("C:\XPClean-web\Settings\XPClean-pics\Toy-box-jpg.jpg", $Toy_Banner)
$Logo_icon = @TempDir & "\Toy-Icon.ico"
FileInstall("C:\XPClean-web\Settings\XPClean-pics\Toy-box-Icon.ico", $Logo_icon)

AdlibEnable("AllTimers", 500)

GuiCreate("   Toy BOX  -  Multi-Station-Timer", 981, 470)
GUISetIcon($Logo_icon)
$Icon_1 = GUICtrlCreatePic($Toy_Banner, 700, 370, 210, 90)
GUICtrlSetState( -1, $GUI_DISABLE)
GUICtrlSetCursor(-1, 0)
GUICtrlSetTip(-1, "Click here - to Donate Now!!")

;Top computer label
GuiCtrlCreateLabel( $Header_1 & "s", 0, 0, 980, 20, $SS_CENTER, $WS_EX_STATICEDGE)
GUICtrlSetFont( -1, 12, 700)
GUICtrlSetColor( -1, 0xFFFFFF)
GUICtrlSetBkColor( -1, 0x876B53)

;Input 1
$TButton_[1] = GuiCtrlCreateButton("Start", 0, 70, 50, 20)
$SButton_[1] = GuiCtrlCreateButton("Stop", 50, 70, 50, 20)
$Input_[1] = GuiCtrlCreateInput("", 0, 90, 100, 20, 0x1000)
$Label_[1] = GuiCtrlCreateLabel("", 0, 40, 100, 30, 0x1000)
GUICtrlSetFont ( -1, 16)
GUICtrlSetData($Label_[1], "00:00:00")
GuiCtrlCreateLabel($Header_1 & " 1", 0, 20, 100, 20, $SS_CENTER)
;Input 2
$TButton_[2] = GuiCtrlCreateButton("Start", 110, 70, 50, 20)
$SButton_[2] = GuiCtrlCreateButton("Stop", 160, 70, 50, 20)
$Input_[2] = GuiCtrlCreateInput("", 110, 90, 100, 20, 0x1000)
$Label_[2] = GuiCtrlCreateLabel("", 110, 40, 100, 30, 0x1000)
GUICtrlSetFont ( -1, 16)
GUICtrlSetData($Label_[2], "00:00:00")
GuiCtrlCreateLabel($Header_1 & " 2", 110, 20, 100, 20, $SS_CENTER)
;Input 3
$TButton_[3] = GuiCtrlCreateButton("Start", 220, 70, 50, 20)
$SButton_[3] = GuiCtrlCreateButton("Stop", 270, 70, 50, 20)
$Input_[3] = GuiCtrlCreateInput("", 220, 90, 100, 20, 0x1000)
$Label_[3] = GuiCtrlCreateLabel("", 220, 40, 100, 30, 0x1000)
GUICtrlSetFont ( -1, 16)
GUICtrlSetData($Label_[3], "00:00:00")
GuiCtrlCreateLabel($Header_1 & " 3", 220, 20, 100, 20, $SS_CENTER)
;Input 4
$TButton_[4] = GuiCtrlCreateButton("Start", 330, 70, 50, 20)
$SButton_[4] = GuiCtrlCreateButton("Stop", 380, 70, 50, 20)
$Input_[4] = GuiCtrlCreateInput("", 330, 90, 100, 20, 0x1000)
$Label_[4] = GuiCtrlCreateLabel("", 330, 40, 100, 30, 0x1000)
GUICtrlSetFont ( -1, 16)
GUICtrlSetData($Label_[4], "00:00:00")
GuiCtrlCreateLabel($Header_1 & " 4", 330, 20, 100, 20, $SS_CENTER)
;Input 5
$TButton_[5] = GuiCtrlCreateButton("Start", 440, 70, 50, 20)
$SButton_[5] = GuiCtrlCreateButton("Stop", 490, 70, 50, 20)
$Input_[5] = GuiCtrlCreateInput("", 440, 90, 100, 20, 0x1000)
$Label_[5] = GuiCtrlCreateLabel("", 440, 40, 100, 30, 0x1000)
GUICtrlSetFont ( -1, 16)
GUICtrlSetData($Label_[5], "00:00:00")
GuiCtrlCreateLabel($Header_1 & " 5", 440, 20, 100, 20, $SS_CENTER)
;Input 6
$TButton_[6] = GuiCtrlCreateButton("Start", 550, 70, 50, 20)
$SButton_[6] = GuiCtrlCreateButton("Stop", 600, 70, 50, 20)
$Input_[6] = GuiCtrlCreateInput("", 550, 90, 100, 20, 0x1000)
$Label_[6] = GuiCtrlCreateLabel("", 550, 40, 100, 30, 0x1000)
GUICtrlSetFont ( -1, 16)
GUICtrlSetData($Label_[6], "00:00:00")
GuiCtrlCreateLabel($Header_1 & " 6", 550, 20, 100, 20, $SS_CENTER)
;Input 7
$TButton_[7] = GuiCtrlCreateButton("Start", 660, 70, 50, 20)
$SButton_[7]= GuiCtrlCreateButton("Stop", 710, 70, 50, 20)
$Input_[7] = GuiCtrlCreateInput("", 660, 90, 100, 20, 0x1000)
$Label_[7] = GuiCtrlCreateLabel("", 660, 40, 100, 30, 0x1000)
GUICtrlSetFont ( -1, 16)
GUICtrlSetData($Label_[7], "00:00:00")
GuiCtrlCreateLabel($Header_1 & " 7", 660, 20, 100, 20, $SS_CENTER)
;Input 8
$TButton_[8] = GuiCtrlCreateButton("Start", 770, 70, 50, 20)
$SButton_[8] = GuiCtrlCreateButton("Stop", 820, 70, 50, 20)
$Input_[8] = GuiCtrlCreateInput("", 770, 90, 100, 20, 0x1000)
$Label_[8] = GuiCtrlCreateLabel("", 770, 40, 100, 30, 0x1000)
GUICtrlSetFont (-1, 16)
GUICtrlSetData($Label_[8], "00:00:00")
GuiCtrlCreateLabel($Header_1 & " 8", 770, 20, 100, 20, $SS_CENTER)
;Input 9
$TButton_[9] = GuiCtrlCreateButton("Start", 880, 70, 50, 20)
$SButton_[9]= GuiCtrlCreateButton("Stop", 930, 70, 50, 20)
$Input_[9] = GuiCtrlCreateInput("", 880, 90, 100, 20, 0x1000)
$Label_[9] = GuiCtrlCreateLabel("", 880, 40, 100, 30, 0x1000)
GUICtrlSetFont ( -1, 16)
GUICtrlSetData($Label_[9], "00:00:00")
GuiCtrlCreateLabel($Header_1 & " 9", 880, 20, 100, 20, $SS_CENTER)
;Input 10
$TButton_[10] = GuiCtrlCreateButton("Start", 0, 170, 50, 20)
$SButton_[10] = GuiCtrlCreateButton("Stop", 50, 170, 50, 20)
$Input_[10] = GuiCtrlCreateInput("", 0, 190, 100, 20, 0x1000)
$Label_[10] = GuiCtrlCreateLabel("", 0, 140, 100, 30, 0x1000)
GUICtrlSetFont ( -1, 16)
GUICtrlSetData($Label_[10], "00:00:00")
GuiCtrlCreateLabel($Header_1 & " 10", 0, 120, 100, 20, $SS_CENTER)
;Input 11
$TButton_[11] = GuiCtrlCreateButton("Start", 110, 170, 50, 20)
$SButton_[11] = GuiCtrlCreateButton("Stop", 160, 170, 50, 20)
$Input_[11] = GuiCtrlCreateInput("", 110, 190, 100, 20, 0x1000)
$Label_[11] = GuiCtrlCreateLabel("", 110, 140, 100, 30, 0x1000)
GUICtrlSetFont ( -1, 16)
GUICtrlSetData($Label_[11], "00:00:00")
GuiCtrlCreateLabel($Header_1 & " 11", 110, 120, 100, 20, $SS_CENTER)
;Input 12
$TButton_[12] = GuiCtrlCreateButton("Start", 220, 170, 50, 20)
$SButton_[12] = GuiCtrlCreateButton("Stop", 270, 170, 50, 20)
$Input_[12] = GuiCtrlCreateInput("", 220, 190, 100, 20, 0x1000)
$Label_[12] = GuiCtrlCreateLabel("", 220, 140, 100, 30, 0x1000)
GUICtrlSetFont ( -1, 16)
GUICtrlSetData($Label_[12], "00:00:00")
GuiCtrlCreateLabel($Header_1 & " 12", 220, 120, 100, 20, $SS_CENTER)
;Input 13
$TButton_[13] = GuiCtrlCreateButton("Start", 330, 170, 50, 20)
$SButton_[13] = GuiCtrlCreateButton("Stop", 380, 170, 50, 20)
$Input_[13] = GuiCtrlCreateInput("", 330, 190, 100, 20, 0x1000)
$Label_[13] = GuiCtrlCreateLabel("", 330, 140, 100, 30, 0x1000)
GUICtrlSetFont ( -1, 16)
GUICtrlSetData($Label_[13], "00:00:00")
GuiCtrlCreateLabel($Header_1 & " 13", 330, 120, 100, 20, $SS_CENTER)
;Input 14
$TButton_[14] = GuiCtrlCreateButton("Start", 440, 170, 50, 20)
$SButton_[14] = GuiCtrlCreateButton("Stop", 490, 170, 50, 20)
$Input_[14] = GuiCtrlCreateInput("", 440, 190, 100, 20, 0x1000)
$Label_[14] = GuiCtrlCreateLabel("", 440, 140, 100, 30, 0x1000)
GUICtrlSetFont ( -1, 16)
GUICtrlSetData($Label_[14], "00:00:00")
GuiCtrlCreateLabel($Header_1 & " 14", 440, 120, 100, 20, $SS_CENTER)
;Input 15
$TButton_[15] = GuiCtrlCreateButton("Start", 550, 170, 50, 20)
$SButton_[15] = GuiCtrlCreateButton("Stop", 600, 170, 50, 20)
$Input_[15] = GuiCtrlCreateInput("", 550, 190, 100, 20, 0x1000)
$Label_[15] = GuiCtrlCreateLabel("", 550, 140, 100, 30, 0x1000)
GUICtrlSetFont ( -1, 16)
GUICtrlSetData($Label_[15], "00:00:00")
GuiCtrlCreateLabel($Header_1 & " 15", 550, 120, 100, 20, $SS_CENTER)
;Input 16
$TButton_[16] = GuiCtrlCreateButton("Start", 660, 170, 50, 20)
$SButton_[16] = GuiCtrlCreateButton("Stop", 710, 170, 50, 20)
$Input_[16] = GuiCtrlCreateInput("", 660, 190, 100, 20, 0x1000)
$Label_[16] = GuiCtrlCreateLabel("", 660, 140, 100, 30, 0x1000)
GUICtrlSetFont ( -1, 16)
GUICtrlSetData($Label_[16], "00:00:00")
GuiCtrlCreateLabel($Header_1 & " 16", 660, 120, 100, 20, $SS_CENTER)
;Input 17
$TButton_[17] = GuiCtrlCreateButton("Start", 770, 170, 50, 20)
$SButton_[17] = GuiCtrlCreateButton("Stop", 820, 170, 50, 20)
$Input_[17] = GuiCtrlCreateInput("", 770, 190, 100, 20, 0x1000)
$Label_[17] = GuiCtrlCreateLabel("", 770, 140, 100, 30, 0x1000)
GUICtrlSetFont ( -1, 16)
GUICtrlSetData($Label_[17], "00:00:00")
GuiCtrlCreateLabel($Header_1 & " 17", 770, 120, 100, 20, $SS_CENTER)
;Input 18
$TButton_[18] = GuiCtrlCreateButton("Start", 880, 170, 50, 20)
$SButton_[18] = GuiCtrlCreateButton("Stop", 930, 170, 50, 20)
$Input_[18] = GuiCtrlCreateInput("", 880, 190, 100, 20, 0x1000)
$Label_[18] = GuiCtrlCreateLabel("", 880, 140, 100, 30, 0x1000)
GUICtrlSetFont ( -1, 16)
GUICtrlSetData($Label_[18], "00:00:00")
GuiCtrlCreateLabel($Header_1 & " 18", 880, 120, 100, 20, $SS_CENTER)

;Middle phones label
GuiCtrlCreateLabel($Header_2 & "s", 0, 220, 980, 20, $SS_CENTER, $WS_EX_STATICEDGE)
GUICtrlSetFont( -1, 12, 700)
GUICtrlSetColor( -1, 0xFFFFFF)
GUICtrlSetBkColor( -1, 0x876B53)

;Input 19
$TButton_[19] = GuiCtrlCreateButton("Start", 0, 290, 50, 20)
$SButton_[19] = GuiCtrlCreateButton("Stop", 50, 290, 50, 20)
$Input_[19] = GuiCtrlCreateInput("", 0, 310, 100, 20, 0x1000)
$Label_[19] = GuiCtrlCreateLabel("", 0, 260, 100, 30, 0x1000)
GUICtrlSetFont ( -1, 16)
GUICtrlSetData($Label_[19], "00:00:00")
GuiCtrlCreateLabel($Header_2 & "  1", 0, 240, 100, 20, $SS_CENTER)
;Input 20
$TButton_[20] = GuiCtrlCreateButton("Start", 110, 290, 50, 20)
$SButton_[20] = GuiCtrlCreateButton("Stop", 160, 290, 50, 20)
$Input_[20] = GuiCtrlCreateInput("", 110, 310, 100, 20, 0x1000)
$Label_[20] = GuiCtrlCreateLabel("", 110, 260, 100, 30, 0x1000)
GUICtrlSetFont ( -1, 16)
GUICtrlSetData($Label_[20], "00:00:00")
GuiCtrlCreateLabel($Header_2 & "  2", 110, 240, 100, 20, $SS_CENTER)
;Input 21
$TButton_[21] = GuiCtrlCreateButton("Start", 220, 290, 50, 20)
$SButton_[21] = GuiCtrlCreateButton("Stop", 270, 290, 50, 20)
$Input_[21] = GuiCtrlCreateInput("", 220, 310, 100, 20, 0x1000)
$Label_[21] = GuiCtrlCreateLabel("", 220, 260, 100, 30, 0x1000)
GUICtrlSetFont ( -1, 16)
GUICtrlSetData($Label_[21], "00:00:00")
GuiCtrlCreateLabel($Header_2 & "  3", 220, 240, 100, 20, $SS_CENTER)
;Input 22
$TButton_[22] = GuiCtrlCreateButton("Start", 330, 290, 50, 20)
$SButton_[22] = GuiCtrlCreateButton("Stop", 380, 290, 50, 20)
$Input_[22] = GuiCtrlCreateInput("", 330, 310, 100, 20, 0x1000)
$Label_[22] = GuiCtrlCreateLabel("", 330, 260, 100, 30, 0x1000)
GUICtrlSetFont ( -1, 16)
GUICtrlSetData($Label_[22], "00:00:00")
GuiCtrlCreateLabel($Header_2 & "  4", 330, 240, 100, 20, $SS_CENTER)
;Input 23
$TButton_[23] = GuiCtrlCreateButton("Start", 440, 290, 50, 20)
$SButton_[23] = GuiCtrlCreateButton("Stop", 490, 290, 50, 20)
$Input_[23] = GuiCtrlCreateInput("", 440, 310, 100, 20, 0x1000)
$Label_[23] = GuiCtrlCreateLabel("", 440, 260, 100, 30, 0x1000)
GUICtrlSetFont ( -1, 16)
GUICtrlSetData($Label_[23], "00:00:00")
GuiCtrlCreateLabel($Header_2 & "  5", 440, 240, 100, 20, $SS_CENTER)
;Input 24
$TButton_[24] = GuiCtrlCreateButton("Start", 550, 290, 50, 20)
$SButton_[24] = GuiCtrlCreateButton("Stop", 600, 290, 50, 20)
$Input_[24] = GuiCtrlCreateInput("", 550, 310, 100, 20, 0x1000)
$Label_[24] = GuiCtrlCreateLabel("", 550, 260, 100, 30, 0x1000)
GUICtrlSetFont ( -1, 16)
GUICtrlSetData($Label_[24], "00:00:00")
GuiCtrlCreateLabel($Header_2 & "  6", 550, 240, 100, 20, $SS_CENTER)
;Input 25
$TButton_[25] = GuiCtrlCreateButton("Start", 660, 290, 50, 20)
$SButton_[25] = GuiCtrlCreateButton("Stop", 710, 290, 50, 20)
$Input_[25] = GuiCtrlCreateInput("", 660, 310, 100, 20, 0x1000)
$Label_[25] = GuiCtrlCreateLabel("", 660, 260, 100, 30, 0x1000)
GUICtrlSetFont ( -1, 16)
GUICtrlSetData($Label_[25], "00:00:00")
GuiCtrlCreateLabel($Header_2 & "  7", 660, 240, 100, 20, $SS_CENTER)
;Input 26
$TButton_[26] = GuiCtrlCreateButton("Start", 770, 290, 50, 20)
$SButton_[26] = GuiCtrlCreateButton("Stop", 820, 290, 50, 20)
$Input_[26] = GuiCtrlCreateInput("", 770, 310, 100, 20, 0x1000)
$Label_[26] = GuiCtrlCreateLabel("", 770, 260, 100, 30, 0x1000)
GUICtrlSetFont ( -1, 16)
GUICtrlSetData($Label_[26], "00:00:00")
GuiCtrlCreateLabel($Header_2 & "  8", 770, 240, 100, 20, $SS_CENTER)
;Input 27
$TButton_[27] = GuiCtrlCreateButton("Start", 880, 290, 50, 20)
$SButton_[27] = GuiCtrlCreateButton("Stop", 930, 290, 50, 20)
$Input_[27] = GuiCtrlCreateInput("", 880, 310, 100, 20, 0x1000)
$Label_[27] = GuiCtrlCreateLabel("", 880, 260, 100, 30, 0x1000)
GUICtrlSetFont ( -1, 16)
GUICtrlSetData($Label_[27], "00:00:00")
GuiCtrlCreateLabel($Header_2 & "  9", 880, 240, 100, 20, $SS_CENTER)

;Bottom PC label
GuiCtrlCreateLabel($Header_3 & "s", 0, 340, 980, 20, $SS_CENTER, $WS_EX_STATICEDGE)
GUICtrlSetFont( -1, 12, 700)
GUICtrlSetColor( -1, 0xFFFFFF)
GUICtrlSetBkColor( -1, 0x876B53)

;Input 28
$TButton_[28] = GuiCtrlCreateButton("Start", 0, 410, 50, 20)
$SButton_[28] = GuiCtrlCreateButton("Stop", 50, 410, 50, 20)
$Input_[28] = GuiCtrlCreateInput("", 0, 430, 100, 20, 0x1000)
$Label_[28] = GuiCtrlCreateLabel("", 0, 380, 100, 30, 0x1000)
GUICtrlSetFont ( -1, 16)
GUICtrlSetData($Label_[28], "00:00:00")
GuiCtrlCreateLabel($Header_3 & " 1", 0, 360, 100, 20, $SS_CENTER)
;Input 29
$TButton_[29] = GuiCtrlCreateButton("Start", 110, 410, 50, 20)
$SButton_[29] = GuiCtrlCreateButton("Stop", 160, 410, 50, 20)
$Input_[29] = GuiCtrlCreateInput("", 110, 430, 100, 20, 0x1000)
$Label_[29] = GuiCtrlCreateLabel("", 110, 380, 100, 30, 0x1000)
GUICtrlSetFont ( -1, 16)
GUICtrlSetData($Label_[29], "00:00:00")
GuiCtrlCreateLabel($Header_3 & " 2", 110, 360, 100, 20, $SS_CENTER)
;Input 30
$TButton_[30] = GuiCtrlCreateButton("Start", 220, 410, 50, 20)
$SButton_[30] = GuiCtrlCreateButton("Stop", 270, 410, 50, 20)
$Input_[30] = GuiCtrlCreateInput("", 220, 430, 100, 20, 0x1000)
$Label_[30] = GuiCtrlCreateLabel("", 220, 380, 100, 30, 0x1000)
GUICtrlSetFont ( -1, 16)
GUICtrlSetData($Label_[30], "00:00:00")
GuiCtrlCreateLabel($Header_3 & " 3", 220, 360, 100, 20, $SS_CENTER)
;Input 31
$TButton_[31] = GuiCtrlCreateButton("Start", 330, 410, 50, 20)
$SButton_[31] = GuiCtrlCreateButton("Stop", 380, 410, 50, 20)
$Input_[31] = GuiCtrlCreateInput("", 330, 430, 100, 20, 0x1000)
$Label_[31] = GuiCtrlCreateLabel("", 330, 380, 100, 30, 0x1000)
GUICtrlSetFont ( -1, 16)
GUICtrlSetData($Label_[31], "00:00:00")
GuiCtrlCreateLabel($Header_3 & " 4", 330, 360, 100, 20, $SS_CENTER)
;Input 32
$TButton_[32] = GuiCtrlCreateButton("Start", 440, 410, 50, 20)
$SButton_[32] = GuiCtrlCreateButton("Stop", 490, 410, 50, 20)
$Input_[32] = GuiCtrlCreateInput("", 440, 430, 100, 20, 0x1000)
$Label_[32] = GuiCtrlCreateLabel("", 440, 380, 100, 30, 0x1000)
GUICtrlSetFont ( -1, 16)
GUICtrlSetData($Label_[32], "00:00:00")
GuiCtrlCreateLabel($Header_3 & " 5", 440, 360, 100, 20, $SS_CENTER)
;Input 33
$TButton_[33] = GuiCtrlCreateButton("Start", 550, 410, 50, 20)
$SButton_[33] = GuiCtrlCreateButton("Stop", 600, 410, 50, 20)
$Input_[33] = GuiCtrlCreateInput("", 550, 430, 100, 20, 0x1000)
$Label_[33] = GuiCtrlCreateLabel("", 550, 380, 100, 30, 0x1000)
GUICtrlSetFont ( -1, 16)
GUICtrlSetData($Label_[33], "00:00:00")
GuiCtrlCreateLabel($Header_3 & " 6", 550, 360, 100, 20, $SS_CENTER)

GUISetState()

While 1
    $msg = GUIGetMsg()
    
    For $xk = 1 to $count
        If $msg = $TButton_[$xk] And GUICtrlRead($Input_[$xk]) >"" Then
            GUICtrlSetState($TButton_[$xk], $GUI_DISABLE)
            GUICtrlSetState($Input_[$xk], $GUI_DISABLE)
            $TimerActive_[$xk] = 1
            $timer_[$xk] = TimerInit()
        ElseIf $msg = $TButton_[$xk] Then
            MsgBox(64,"User Error", "Please Type in a User Name   ", 3)
        EndIf 
        If $msg = $SButton_[$xk] And GUICtrlRead($SButton_[$xk]) ="Reset" Then
            GUICtrlSetData($Label_[$xk], "00:00:00")
            GUICtrlSetData($Input_[$xk], "")
            GUICtrlSetData( $SButton_[$xk], "Stop")
             GUICtrlSetState($TButton_[$xk], $GUI_ENABLE)
            GUICtrlSetState($Input_[$xk], $GUI_ENABLE)

        EndIf
        If $msg = $SButton_[$xk] And GUICtrlRead($Input_[$xk]) >"" And GUICtrlRead($SButton_[$xk]) ="Stop" Then
            $TimerActive_[$xk] = 0
            GUICtrlSetData( $SButton_[$xk], "Reset")
                     ;
            GUICtrlSetColor($Label_[$xk], 0x000000)
            $Name = GUICtrlRead ($Input_[$xk])
        ;
            If $xk < 19 Then
            $Unit = $Header_1 & "  " & $xk
            EndIf
            If $xk >= 19 And $xk < 28 Then
            $Unit = $Header_2 & "   " & $xk-18
            EndIf
            If $xk >= 28 Then
            $Unit = $Header_3 & "   " & $xk-27
            EndIf
            RecordStuff()
        EndIf
        
        If $xk = 33 Then ExitLoop
    Next
    If $msg = $GUI_EVENT_CLOSE Then ExitLoop
WEnd

Func AllTimers()
    Local $Secs, $Mins, $Hour
    For $ck = 1 to $count
        
        If $TimerActive_[$ck] Then
            _TicksToTime(Int(TimerDiff($timer_[$ck])), $Hour, $Mins, $Secs)
            $Time_[$ck] = StringFormat("%02i:%02i:%02i", $Hour, $Mins, $Secs)
            If $sTime_[$ck] <> $Time_[$ck] Then GUICtrlSetData($Label_[$ck], $Time_[$ck])
            If $Mins > 29 Then GUICtrlSetColor($Label_[$ck], 0xff0000)
        EndIf
    Next
EndFunc

Func RecordStuff ()
    $LogStuff = FileOpen ($Today_File, 1)
    FileWriteLine ($LogStuff, "Station: " & $Unit & @CRLF)
    FileWriteLine ($LogStuff, "User name: " & (GUICtrlRead($Input_[$xk])) & @CRLF)
    FileWriteLine ($LogStuff, "Total time: " & (GUICtrlRead($Label_[$xk])) & @CRLF & @CRLF)
    FileClose ($LogStuff)
    
EndFunc

8)

(added my toyBOX sign)

EDIT

changed to turn numbers red at 30 minutes not 31

If $Mins > 29 Then GUICtrlSetColor($Label_[$ck], 0xff0000

8)

Edited by Valuater

NEWHeader1.png

Link to comment
Share on other sites

am I missing anything?

the script doesn't seem to start counting on my PC

The speed of sound is defined by the distance from door to computer divided by the time interval needed to close the media player and pull up your pants when your mom shouts "OH MY GOD WHAT ARE YOU DOING!!!"

Link to comment
Share on other sites

if your going to use an array of controls why not use 1 loop to create them?

#include <GUIConstants.au3>
#include <Date.au3>

Dim $Header_1 = "Machine"
Dim $Header_2 = "Line"
Dim $Header_3 = "Office"
Dim $Name, $TotalTime, $Unit, $count = 33
Dim $TimerActive_[50], $Label_[50], $TButton_[50], $SButton_[50], $Input_[50], $Label_[50]
Dim $Time_[50], $Timer_[50], $sTime_[50], $xk, $ck, $Left = 0, $Top = 20, $X

$Today_File = @MON & "-" & @MDAY & "-" & @YEAR & ".txt"
$Log = FileOpen($Today_File, 1)
FileWriteLine($Log, "Logfile started: " & _DateTimeFormat( _NowCalc(), 0) & @CRLF & @CRLF)
FileClose($Log)

$Toy_Logo = @TempDir & "\Toy2-logo.jpg"
FileInstall("C:\XPClean-web\Settings\XPClean-pics\Toy-box2-jpg.jpg", $Toy_Logo)
$Toy_Banner = @TempDir & "\Toy-banr.jpg"
FileInstall("C:\XPClean-web\Settings\XPClean-pics\Toy-box-jpg.jpg", $Toy_Banner)
$Logo_icon = @TempDir & "\Toy-Icon.ico"
FileInstall("C:\XPClean-web\Settings\XPClean-pics\Toy-box-Icon.ico", $Logo_icon)

AdlibEnable("AllTimers", 500)

GUICreate("   Toy BOX  -  Multi-Station-Timer", 981, 470)
GUISetIcon($Logo_icon)
$Icon_1 = GUICtrlCreatePic($Toy_Banner, 700, 370, 210, 90)
GUICtrlSetState(-1, $GUI_DISABLE)
GUICtrlSetCursor(-1, 0)
GUICtrlSetTip(-1, "Click here - to Donate Now!!")

;Top computer label
GUICtrlCreateLabel($Header_1 & "s", 0, 0, 980, 20, $SS_CENTER, $WS_EX_STATICEDGE)
GUICtrlSetFont(-1, 12, 700)
GUICtrlSetColor(-1, 0xFFFFFF)
GUICtrlSetBkColor(-1, 0x876B53)

;Middle phones label
GUICtrlCreateLabel($Header_2 & "s", 0, 220, 980, 20, $SS_CENTER, $WS_EX_STATICEDGE)
GUICtrlSetFont(-1, 12, 700)
GUICtrlSetColor(-1, 0xFFFFFF)
GUICtrlSetBkColor(-1, 0x876B53)

;Bottom PC label
GUICtrlCreateLabel($Header_3 & "s", 0, 340, 980, 20, $SS_CENTER, $WS_EX_STATICEDGE)
GUICtrlSetFont(-1, 12, 700)
GUICtrlSetColor(-1, 0xFFFFFF)
GUICtrlSetBkColor(-1, 0x876B53)

For $X = 1 To 9
; row 1
    GUICtrlCreateLabel($Header_1 & " " & $X, $Left, $Top, 100, 20, $SS_CENTER)
    $Label_[$X] = GUICtrlCreateLabel("", $Left, $Top + 20, 100, 30, 0x1000)
    GUICtrlSetFont($Label_[$X], 16)
    GUICtrlSetData($Label_[$X], "00:00:00")
    $TButton_[$X] = GUICtrlCreateButton("Start", $Left, $Top + 50, 50, 20)
    $SButton_[$X] = GUICtrlCreateButton("Stop", $Left + 50, $Top + 50, 50, 20)
    $Input_[$X] = GUICtrlCreateInput("", $Left, $Top + 70, 100, 20, 0x1000)
    
; row 2
    GUICtrlCreateLabel($Header_1 & " " & $X + 9, $Left, $Top + 100, 100, 20, $SS_CENTER)
    $Label_[$X + 9] = GUICtrlCreateLabel("", $Left, $Top + 120, 100, 30, 0x1000)
    GUICtrlSetFont($Label_[$X + 9], 16)
    GUICtrlSetData($Label_[$X + 9], "00:00:00")
    $TButton_[$X + 9] = GUICtrlCreateButton("Start", $Left, $Top + 150, 50, 20)
    $SButton_[$X + 9] = GUICtrlCreateButton("Stop", $Left + 50, $Top + 150, 50, 20)
    $Input_[$X + 9] = GUICtrlCreateInput("", $Left, $Top + 170, 100, 20, 0x1000)
    
; row 3
    GUICtrlCreateLabel($Header_2 & " " & $X, $Left, $Top + 220, 100, 20, $SS_CENTER)
    $Label_[$X + 18] = GUICtrlCreateLabel("", $Left, $Top + 240, 100, 30, 0x1000)
    GUICtrlSetFont($Label_[$X + 18], 16)
    GUICtrlSetData($Label_[$X + 18], "00:00:00")
    $TButton_[$X + 18] = GUICtrlCreateButton("Start", $Left, $Top + 270, 50, 20)
    $SButton_[$X + 18] = GUICtrlCreateButton("Stop", $Left + 50, $Top + 270, 50, 20)
    $Input_[$X + 18] = GUICtrlCreateInput("", $Left, $Top + 290, 100, 20, 0x1000)
    
; row 4
    If $X < 7 Then
        GUICtrlCreateLabel($Header_3 & " " & $X, $Left, $Top + 340, 100, 20, $SS_CENTER)
        $Label_[$X + 27] = GUICtrlCreateLabel("", $Left, $Top + 360, 100, 30, 0x1000)
        GUICtrlSetFont($Label_[$X + 27], 16)
        GUICtrlSetData($Label_[$X + 27], "00:00:00")
        $TButton_[$X + 27] = GUICtrlCreateButton("Start", $Left, $Top + 390, 50, 20)
        $SButton_[$X + 27] = GUICtrlCreateButton("Stop", $Left + 50, $Top + 390, 50, 20)
        $Input_[$X + 27] = GUICtrlCreateInput("", $Left, $Top + 410, 100, 20, 0x1000)
    EndIf
    $Left = $Left + 110
Next

GUISetState()

While 1
    $msg = GUIGetMsg()
    
    For $xk = 1 To $count
        If $msg = $TButton_[$xk] And GUICtrlRead($Input_[$xk]) > "" Then
            GUICtrlSetState($TButton_[$xk], $GUI_DISABLE)
            GUICtrlSetState($Input_[$xk], $GUI_DISABLE)
            $TimerActive_[$xk] = 1
            $Timer_[$xk] = TimerInit()
        ElseIf $msg = $TButton_[$xk] Then
            MsgBox(64, "User Error", "Please Type in a User Name   ", 3)
        EndIf
        If $msg = $SButton_[$xk] And GUICtrlRead($SButton_[$xk]) = "Reset" Then
            GUICtrlSetData($Label_[$xk], "00:00:00")
            GUICtrlSetData($Input_[$xk], "")
            GUICtrlSetData($SButton_[$xk], "Stop")
        EndIf
        If $msg = $SButton_[$xk] And GUICtrlRead($Input_[$xk]) > "" And GUICtrlRead($SButton_[$xk]) = "Stop" Then
            $TimerActive_[$xk] = 0
            GUICtrlSetData($SButton_[$xk], "Reset")
            GUICtrlSetState($TButton_[$xk], $GUI_ENABLE)
            GUICtrlSetState($Input_[$xk], $GUI_ENABLE)
        ;
            GUICtrlSetColor($Label_[$xk], 0x000000)
            $Name = GUICtrlRead($Input_[$xk])
        ;
            If $xk < 19 Then
                $Unit = $Header_1 & "  " & $xk
            EndIf
            If $xk >= 19 And $xk < 28 Then
                $Unit = $Header_2 & "   " & $xk - 18
            EndIf
            If $xk >= 28 Then
                $Unit = $Header_3 & "   " & $xk - 27
            EndIf
            RecordStuff()
        EndIf
        
        If $xk = 33 Then ExitLoop
    Next
    If $msg = $GUI_EVENT_CLOSE Then ExitLoop
WEnd

Func AllTimers()
    Local $Secs, $Mins, $Hour
    For $ck = 1 To $count
        
        If $TimerActive_[$ck] Then
            _TicksToTime(Int(TimerDiff($Timer_[$ck])), $Hour, $Mins, $Secs)
            $Time_[$ck] = StringFormat("%02i:%02i:%02i", $Hour, $Mins, $Secs)
            If $sTime_[$ck] <> $Time_[$ck] Then GUICtrlSetData($Label_[$ck], $Time_[$ck])
            If $Mins > 29 Then GUICtrlSetColor($Label_[$ck], 0xff0000)
        EndIf
    Next
EndFunc  ;==>AllTimers

Func RecordStuff()
    $LogStuff = FileOpen($Today_File, 1)
    FileWriteLine($LogStuff, "Station: " & $Unit & @CRLF)
    FileWriteLine($LogStuff, "User name: " & (GUICtrlRead($Input_[$xk])) & @CRLF)
    FileWriteLine($LogStuff, "Total time: " & (GUICtrlRead($Label_[$xk])) & @CRLF & @CRLF)
    FileClose($LogStuff)
    
EndFunc  ;==>RecordStuff
Edited by gafrost

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Link to comment
Share on other sites

Found a flaw in the GUI

after starting the timer(pressing "start" and the button greys out)

pressing stop afterwards(pressing "stop" and the "start" button becomes enabled)

after that, pressing "start" button again and you will see what happens...

Pardon me for picking, it's just my career habit

The speed of sound is defined by the distance from door to computer divided by the time interval needed to close the media player and pull up your pants when your mom shouts "OH MY GOD WHAT ARE YOU DOING!!!"

Link to comment
Share on other sites

Found a flaw in the GUI

after starting the timer(pressing "start" and the button greys out)

pressing stop afterwards(pressing "stop" and the "start" button becomes enabled)

after that, pressing "start" button again and you will see what happens...

Pardon me for picking, it's just my career habit

Never apologize for finding a problem. B)

Unfound problems nearly always bite someone.

Gene

Edited by Gene

[font="Verdana"]Thanks for the response.Gene[/font]Yes, I know the punctuation is not right...

Link to comment
Share on other sites

Found a flaw in the GUI

after starting the timer(pressing "start" and the button greys out)

pressing stop afterwards(pressing "stop" and the "start" button becomes enabled)

after that, pressing "start" button again and you will see what happens...

Pardon me for picking, it's just my career habit

which GUI

my last post or the GUI from gafrost

( i just tested mine again and it worked)

HOLD ON I THINK I SEE IT

????

8)

Edited by Valuater

NEWHeader1.png

Link to comment
Share on other sites

OK

i got it

#include <GUIConstants.au3>
#include <Date.au3>

Dim $Header_1 = "Machine"
Dim $Header_2 = "Line"
Dim $Header_3 = "Office"
Dim $Name, $TotalTime, $Unit, $count = 33
Dim $TimerActive_[50], $Label_[50], $TButton_[50], $SButton_[50], $Input_[50], $Label_[50]
Dim $Time_[50], $Timer_[50], $sTime_[50], $xk, $ck, $Left = 0, $Top = 20, $X

$Today_File = @MON & "-" & @MDAY & "-" & @YEAR & ".txt"
$Log = FileOpen($Today_File, 1)
FileWriteLine($Log, "Logfile started: " & _DateTimeFormat( _NowCalc(), 0) & @CRLF & @CRLF)
FileClose($Log)

$Toy_Logo = @TempDir & "\Toy2-logo.jpg"
FileInstall("C:\XPClean-web\Settings\XPClean-pics\Toy-box2-jpg.jpg", $Toy_Logo)
$Toy_Banner = @TempDir & "\Toy-banr.jpg"
FileInstall("C:\XPClean-web\Settings\XPClean-pics\Toy-box-jpg.jpg", $Toy_Banner)
$Logo_icon = @TempDir & "\Toy-Icon.ico"
FileInstall("C:\XPClean-web\Settings\XPClean-pics\Toy-box-Icon.ico", $Logo_icon)

AdlibEnable("AllTimers", 500)

GUICreate("   Toy BOX  -  Multi-Station-Timer", 981, 470)
GUISetIcon($Logo_icon)
$Icon_1 = GUICtrlCreatePic($Toy_Banner, 700, 370, 210, 90)
GUICtrlSetState(-1, $GUI_DISABLE)
GUICtrlSetCursor(-1, 0)
GUICtrlSetTip(-1, "Click here - to Donate Now!!")

;Top computer label
GUICtrlCreateLabel($Header_1 & "s", 0, 0, 980, 20, $SS_CENTER, $WS_EX_STATICEDGE)
GUICtrlSetFont(-1, 12, 700)
GUICtrlSetColor(-1, 0xFFFFFF)
GUICtrlSetBkColor(-1, 0x876B53)

;Middle phones label
GUICtrlCreateLabel($Header_2 & "s", 0, 220, 980, 20, $SS_CENTER, $WS_EX_STATICEDGE)
GUICtrlSetFont(-1, 12, 700)
GUICtrlSetColor(-1, 0xFFFFFF)
GUICtrlSetBkColor(-1, 0x876B53)

;Bottom PC label
GUICtrlCreateLabel($Header_3 & "s", 0, 340, 980, 20, $SS_CENTER, $WS_EX_STATICEDGE)
GUICtrlSetFont(-1, 12, 700)
GUICtrlSetColor(-1, 0xFFFFFF)
GUICtrlSetBkColor(-1, 0x876B53)

For $X = 1 To 9
; row 1
    GUICtrlCreateLabel($Header_1 & " " & $X, $Left, $Top, 100, 20, $SS_CENTER)
    $Label_[$X] = GUICtrlCreateLabel("", $Left, $Top + 20, 100, 30, 0x1000)
    GUICtrlSetFont($Label_[$X], 16)
    GUICtrlSetData($Label_[$X], "00:00:00")
    $TButton_[$X] = GUICtrlCreateButton("Start", $Left, $Top + 50, 50, 20)
    $SButton_[$X] = GUICtrlCreateButton("Stop", $Left + 50, $Top + 50, 50, 20)
    $Input_[$X] = GUICtrlCreateInput("", $Left, $Top + 70, 100, 20, 0x1000)
    
; row 2
    GUICtrlCreateLabel($Header_1 & " " & $X + 9, $Left, $Top + 100, 100, 20, $SS_CENTER)
    $Label_[$X + 9] = GUICtrlCreateLabel("", $Left, $Top + 120, 100, 30, 0x1000)
    GUICtrlSetFont($Label_[$X + 9], 16)
    GUICtrlSetData($Label_[$X + 9], "00:00:00")
    $TButton_[$X + 9] = GUICtrlCreateButton("Start", $Left, $Top + 150, 50, 20)
    $SButton_[$X + 9] = GUICtrlCreateButton("Stop", $Left + 50, $Top + 150, 50, 20)
    $Input_[$X + 9] = GUICtrlCreateInput("", $Left, $Top + 170, 100, 20, 0x1000)
    
; row 3
    GUICtrlCreateLabel($Header_2 & " " & $X, $Left, $Top + 220, 100, 20, $SS_CENTER)
    $Label_[$X + 18] = GUICtrlCreateLabel("", $Left, $Top + 240, 100, 30, 0x1000)
    GUICtrlSetFont($Label_[$X + 18], 16)
    GUICtrlSetData($Label_[$X + 18], "00:00:00")
    $TButton_[$X + 18] = GUICtrlCreateButton("Start", $Left, $Top + 270, 50, 20)
    $SButton_[$X + 18] = GUICtrlCreateButton("Stop", $Left + 50, $Top + 270, 50, 20)
    $Input_[$X + 18] = GUICtrlCreateInput("", $Left, $Top + 290, 100, 20, 0x1000)
    
; row 4
    If $X < 7 Then
        GUICtrlCreateLabel($Header_3 & " " & $X, $Left, $Top + 340, 100, 20, $SS_CENTER)
        $Label_[$X + 27] = GUICtrlCreateLabel("", $Left, $Top + 360, 100, 30, 0x1000)
        GUICtrlSetFont($Label_[$X + 27], 16)
        GUICtrlSetData($Label_[$X + 27], "00:00:00")
        $TButton_[$X + 27] = GUICtrlCreateButton("Start", $Left, $Top + 390, 50, 20)
        $SButton_[$X + 27] = GUICtrlCreateButton("Stop", $Left + 50, $Top + 390, 50, 20)
        $Input_[$X + 27] = GUICtrlCreateInput("", $Left, $Top + 410, 100, 20, 0x1000)
    EndIf
    $Left = $Left + 110
Next

GUISetState()

While 1
    $msg = GUIGetMsg()
    
    For $xk = 1 To $count
        If $msg = $TButton_[$xk] And GUICtrlRead($Input_[$xk]) > "" Then
            GUICtrlSetState($TButton_[$xk], $GUI_DISABLE)
            GUICtrlSetState($Input_[$xk], $GUI_DISABLE)
            $TimerActive_[$xk] = 1
            $Timer_[$xk] = TimerInit()
        ElseIf $msg = $TButton_[$xk] Then
            MsgBox(64, "User Error", "Please Type in a User Name   ", 3)
        EndIf
        If $msg = $SButton_[$xk] And GUICtrlRead($SButton_[$xk]) = "Reset" Then
            GUICtrlSetData($Label_[$xk], "00:00:00")
            GUICtrlSetData($Input_[$xk], "")
            GUICtrlSetData($SButton_[$xk], "Stop")
            GUICtrlSetState($TButton_[$xk], $GUI_ENABLE)
            GUICtrlSetState($Input_[$xk], $GUI_ENABLE)
        EndIf
        If $msg = $SButton_[$xk] And GUICtrlRead($Input_[$xk]) > "" And GUICtrlRead($SButton_[$xk]) = "Stop" Then
            $TimerActive_[$xk] = 0
            GUICtrlSetData($SButton_[$xk], "Reset")
            
       ;
            GUICtrlSetColor($Label_[$xk], 0x000000)
            $Name = GUICtrlRead($Input_[$xk])
       ;
            If $xk < 19 Then
                $Unit = $Header_1 & "  " & $xk
            EndIf
            If $xk >= 19 And $xk < 28 Then
                $Unit = $Header_2 & "   " & $xk - 18
            EndIf
            If $xk >= 28 Then
                $Unit = $Header_3 & "   " & $xk - 27
            EndIf
            RecordStuff()
        EndIf
        
        If $xk = 33 Then ExitLoop
    Next
    If $msg = $GUI_EVENT_CLOSE Then ExitLoop
WEnd

Func AllTimers()
    Local $Secs, $Mins, $Hour
    For $ck = 1 To $count
        
        If $TimerActive_[$ck] Then
            _TicksToTime(Int(TimerDiff($Timer_[$ck])), $Hour, $Mins, $Secs)
            $Time_[$ck] = StringFormat("%02i:%02i:%02i", $Hour, $Mins, $Secs)
            If $sTime_[$ck] <> $Time_[$ck] Then GUICtrlSetData($Label_[$ck], $Time_[$ck])
            If $Mins > 29 Then GUICtrlSetColor($Label_[$ck], 0xff0000)
        EndIf
    Next
EndFunc ;==>AllTimers

Func RecordStuff()
    $LogStuff = FileOpen($Today_File, 1)
    FileWriteLine($LogStuff, "Station: " & $Unit & @CRLF)
    FileWriteLine($LogStuff, "User name: " & (GUICtrlRead($Input_[$xk])) & @CRLF)
    FileWriteLine($LogStuff, "Total time: " & (GUICtrlRead($Label_[$xk])) & @CRLF & @CRLF)
    FileClose($LogStuff)
    
EndFunc ;==>RecordStuff

8)

it was in the while loop... this is gafrosts gui ( now the better one )

Edited by Valuater

NEWHeader1.png

Link to comment
Share on other sites

UPdated

User's Choice of...

Headers ( Titles over timers )

How Many timers you want

3 Timers to 39 Timers

#include <GUIConstants.au3>
#include <Date.au3>

Dim $Header_1 = "Machine"
Dim $Header_2 = "Line"
Dim $Header_3 = "Office"
Dim $Name, $TotalTime, $Unit, $count
Dim $TimerActive_[50], $Label_[50], $TButton_[50], $SButton_[50], $Input_[50], $Label_[50]
Dim $Time_[50], $Timer_[50], $sTime_[50], $xk, $ck, $tk, $pk, $Left = 0, $Top = 20, $X, $Radx, $Rad_[11]

$Today_File = @MON & "-" & @MDAY & "-" & @YEAR & ".txt"
$Log = FileOpen($Today_File, 1)
FileWriteLine($Log, "Logfile started: " & _DateTimeFormat( _NowCalc(), 0) & @CRLF & @CRLF)
FileClose($Log)

$Toy_Logo = @TempDir & "\Toy2-logo.jpg"
FileInstall("C:\XPClean-web\Settings\XPClean-pics\Toy-box2-jpg.jpg", $Toy_Logo)
$Toy_Banner = @TempDir & "\Toy-banr.jpg"
FileInstall("C:\XPClean-web\Settings\XPClean-pics\Toy-box-jpg.jpg", $Toy_Banner)
$Logo_icon = @TempDir & "\Toy-Icon.ico"
FileInstall("C:\XPClean-web\Settings\XPClean-pics\Toy-box-Icon.ico", $Logo_icon)

Setup()

AdlibEnable("AllTimers", 500)

GUICreate("   Toy BOX  -  Multi-Station-Timer", (110 * $pk), 470)
GUISetIcon($Logo_icon)


;Top computer label
GUICtrlCreateLabel($Header_1 & "s", 0, 0, (110 * $pk), 20, $SS_CENTER, $WS_EX_STATICEDGE)
GUICtrlSetFont(-1, 12, 700)
GUICtrlSetColor(-1, 0xFFFFFF)
GUICtrlSetBkColor(-1, 0x876B53)

;Middle phones label
GUICtrlCreateLabel($Header_2 & "s", 0, 220, (110 * $pk), 20, $SS_CENTER, $WS_EX_STATICEDGE)
GUICtrlSetFont(-1, 12, 700)
GUICtrlSetColor(-1, 0xFFFFFF)
GUICtrlSetBkColor(-1, 0x876B53)

;Bottom PC label
GUICtrlCreateLabel($Header_3 & "s", 0, 340, (110 * $pk), 20, $SS_CENTER, $WS_EX_STATICEDGE)
GUICtrlSetFont(-1, 12, 700)
GUICtrlSetColor(-1, 0xFFFFFF)
GUICtrlSetBkColor(-1, 0x876B53)

For $X = 1 To $pk
; row 1
    GUICtrlCreateLabel($Header_1 & " " & $X, $Left, $Top, 100, 20, $SS_CENTER)
    $Label_[$X] = GUICtrlCreateLabel("", $Left, $Top + 20, 100, 30, 0x1000)
    GUICtrlSetFont($Label_[$X], 16)
    GUICtrlSetData($Label_[$X], "00:00:00")
    $TButton_[$X] = GUICtrlCreateButton("Start", $Left, $Top + 50, 50, 20)
    $SButton_[$X] = GUICtrlCreateButton("Stop", $Left + 50, $Top + 50, 50, 20)
    $Input_[$X] = GUICtrlCreateInput("", $Left, $Top + 70, 100, 20, 0x1000)
   ;MsgBox(0,$pk, $Radx & @CRLF & $count)
; row 2
    GUICtrlCreateLabel($Header_1 & " " & ($X + (($count +1)* .25)), $Left, $Top + 100, 100, 20, $SS_CENTER)
    $Label_[($X + (($count +1)* .25))] = GUICtrlCreateLabel("", $Left, $Top + 120, 100, 30, 0x1000)
    GUICtrlSetFont($Label_[($X + (($count +1)* .25))], 16)
    GUICtrlSetData($Label_[($X + (($count +1)* .25))], "00:00:00")
    $TButton_[($X + (($count +1)* .25))] = GUICtrlCreateButton("Start", $Left, $Top + 150, 50, 20)
    $SButton_[($X + (($count +1)* .25))] = GUICtrlCreateButton("Stop", $Left + 50, $Top + 150, 50, 20)
    $Input_[($X + (($count +1)* .25))] = GUICtrlCreateInput("", $Left, $Top + 170, 100, 20, 0x1000)
    
; row 3
    GUICtrlCreateLabel($Header_2 & " " & $X, $Left, $Top + 220, 100, 20, $SS_CENTER)
    $Label_[($X + (($count +1)* .5))] = GUICtrlCreateLabel("", $Left, $Top + 240, 100, 30, 0x1000)
    GUICtrlSetFont($Label_[($X + (($count +1)* .5))], 16)
    GUICtrlSetData($Label_[($X + (($count +1)* .5))], "00:00:00")
    $TButton_[($X + (($count +1)* .5))] = GUICtrlCreateButton("Start", $Left, $Top + 270, 50, 20)
    $SButton_[($X + (($count +1)* .5))] = GUICtrlCreateButton("Stop", $Left + 50, $Top + 270, 50, 20)
    $Input_[($X + (($count +1)* .5))] = GUICtrlCreateInput("", $Left, $Top + 290, 100, 20, 0x1000)
    
; row 4
   
    If ($X + (($count +1)* .75)) = ($count + 1) Then
        $Icon_1 = GUICtrlCreatePic($Toy_Banner, $Left, $Top + 360, 100, 50)
        GUICtrlSetState(-1, $GUI_DISABLE)
        ExitLoop
    EndIf
    GUICtrlCreateLabel($Header_3 & " " & $X, $Left, $Top + 340, 100, 20, $SS_CENTER)
    $Label_[($X + (($count +1)* .75))] = GUICtrlCreateLabel("", $Left, $Top + 360, 100, 30, 0x1000)
    GUICtrlSetFont($Label_[($X + (($count +1)* .75))], 16)
    GUICtrlSetData($Label_[($X + (($count +1)* .75))], "00:00:00")
    $TButton_[($X + (($count +1)* .75))] = GUICtrlCreateButton("Start", $Left, $Top + 390, 50, 20)
    $SButton_[($X + (($count +1)* .75))] = GUICtrlCreateButton("Stop", $Left + 50, $Top + 390, 50, 20)
    $Input_[($X + (($count +1)* .75))] = GUICtrlCreateInput("", $Left, $Top + 410, 100, 20, 0x1000)
    
    $Left = $Left + 110
Next

GUISetState()

While 1
    $msg = GUIGetMsg()
    
    For $xk = 1 To $count
        If $msg = $TButton_[$xk] And GUICtrlRead($Input_[$xk]) > "" Then
            GUICtrlSetState($TButton_[$xk], $GUI_DISABLE)
            GUICtrlSetState($Input_[$xk], $GUI_DISABLE)
            $TimerActive_[$xk] = 1
            $Timer_[$xk] = TimerInit()
        ElseIf $msg = $TButton_[$xk] Then
            MsgBox(64, "User Error:  " & $xk, "Please Type in a User Name   ", 3)
        EndIf
        If $msg = $SButton_[$xk] And GUICtrlRead($SButton_[$xk]) = "Reset" Then
            GUICtrlSetData($Label_[$xk], "00:00:00")
            GUICtrlSetData($Input_[$xk], "")
            GUICtrlSetData($SButton_[$xk], "Stop")
            GUICtrlSetState($TButton_[$xk], $GUI_ENABLE)
            GUICtrlSetState($Input_[$xk], $GUI_ENABLE)
        EndIf
        If $msg = $SButton_[$xk] And GUICtrlRead($Input_[$xk]) > "" And GUICtrlRead($SButton_[$xk]) = "Stop" Then
            $TimerActive_[$xk] = 0
            GUICtrlSetData($SButton_[$xk], "Reset")
            
       ;
            GUICtrlSetColor($Label_[$xk], 0x000000)
            $Name = GUICtrlRead($Input_[$xk])
       ;
            If $xk <= (($count +1)* .5) Then
                $Unit = $Header_1 & "  " & $xk
            EndIf
            If $xk > (($count +1)* .5) And $xk <= (($count +1)* .75) Then
                $Unit = $Header_2 & "   " & ($xk - (($count +1)* .5))
            EndIf
            If $xk > (($count +1)* .75) Then
                $Unit = $Header_3 & "   " & ($xk - (($count +1)* .75))
            EndIf
            RecordStuff()
        EndIf
    Next
    If $msg = $GUI_EVENT_CLOSE Then ExitLoop
WEnd

Func AllTimers()
    Local $Secs, $Mins, $Hour
    For $ck = 1 To $count
        
        If $TimerActive_[$ck] Then
            _TicksToTime(Int(TimerDiff($Timer_[$ck])), $Hour, $Mins, $Secs)
            $Time_[$ck] = StringFormat("%02i:%02i:%02i", $Hour, $Mins, $Secs)
            If $sTime_[$ck] <> $Time_[$ck] Then GUICtrlSetData($Label_[$ck], $Time_[$ck])
            If $Mins > 29 Then GUICtrlSetColor($Label_[$ck], 0xff0000)
        EndIf
    Next
EndFunc ;==>AllTimers

Func RecordStuff()
    $LogStuff = FileOpen($Today_File, 1)
    FileWriteLine($LogStuff, "Station: " & $Unit & @CRLF)
    FileWriteLine($LogStuff, "User name: " & (GUICtrlRead($Input_[$xk])) & @CRLF)
    FileWriteLine($LogStuff, "Total time: " & (GUICtrlRead($Label_[$xk])) & @CRLF & @CRLF)
    FileClose($LogStuff)
    
EndFunc ;==>RecordStuff 

Func Setup()
$Set_win = GUICreate("   Toy BOX  -  Multi-Station-Timer", 350, 310)
GUISetIcon($Logo_icon)
$Icon_1 = GUICtrlCreatePic($Toy_Logo, 240, 10, 100, 250)
GUICtrlSetState(-1, $GUI_DISABLE)
GUICtrlCreateGroup("3 Group Names", 10, 10, 220, 135)
$Head_1 = GUICtrlCreateInput($Header_1, 30, 40, 150, 20)
$Head_2 = GUICtrlCreateInput($Header_2, 30, 75, 150, 20)
$Head_3 = GUICtrlCreateInput($Header_3, 30, 110, 150, 20)
GUICtrlCreateGroup("Number of Timers", 10, 155, 220, 150)
$Note = GUICtrlCreateLabel("19 Total Timers", 30, 175, 150, 20, $SS_SUNKEN + $SS_CENTER  ) 
$Rad_[1] = GUICtrlCreateRadio("3", 40, 200, 30, 20)
$Rad_[2] = GUICtrlCreateRadio("7", 40, 220, 30, 20)
$Rad_[3] = GUICtrlCreateRadio("11", 40, 240, 30, 20)
$Rad_[4] = GUICtrlCreateRadio("15", 40, 260, 30, 20)
$Rad_[5] = GUICtrlCreateRadio("19", 40, 280, 30, 20)
GUICtrlSetState( -1, $GUI_CHECKED )
$Rad_[6] = GUICtrlCreateRadio("23", 140, 200, 30, 20)
$Rad_[7] = GUICtrlCreateRadio("27", 140, 220, 30, 20)
$Rad_[8] = GUICtrlCreateRadio("31", 140, 240, 30, 20)
$Rad_[9] = GUICtrlCreateRadio("35", 140, 260, 30, 20)
$Rad_[10] = GUICtrlCreateRadio("39", 140, 280, 30, 20)
$Create = GUICtrlCreateButton("Create", 250, 270, 80, 30)

GUISetState()

While 1
    $msg2 = GUIGetMsg()
    If $msg2 = $Create Then
        $Header_1 = GUICtrlRead($Head_1)
        $Header_2 = GUICtrlRead($Head_2)
        $Header_3 = GUICtrlRead($Head_3)
        For $tk = 1 to 10
            If GUICtrlRead($Rad_[$tk]) = $GUI_CHECKED Then
                $pk = $tk
                $Radx = $tk * 2 
                $count = (($tk * 4)-1)
                ExitLoop
            EndIf
        Next
        ExitLoop
    EndIf
    For $t = 1 to 10 
        If GUICtrlRead($Rad_[$t]) = $GUI_CHECKED Then
                GUICtrlSetData( $Note, (($t * 4)-1) & " Total Timers")
                ExitLoop
        EndIf
    Next    
    If $msg2 = $GUI_EVENT_CLOSE Then ExitLoop
    Sleep(70)
WEnd

GUIDelete($Set_win)
EndFunc

8)

NEWHeader1.png

Link to comment
Share on other sites

Man, I don't check on this thread for a couple days and look what happens :)

Anyway, I changed mine up a bit. I didn't use the functions originaly posted because I don't have the Beta and I was a bit dissapointed when it didn't work for me. I'll get the beta later on and try it then. What I did do with this one though is:

A) Add more timers. (The requirements for this project changed)

B) Added a tabbed UI. Much cleaner appearance.

C) Don't know if this will complicate anything but I needed two different timers. One set for 30 minutes and the other set for 15 minutes.

I liked this check better in the timer: If $Mins = 30 Then GUICtrlSetColor($Label_[$ck], 0xff0000.

Valuator, thanks a *TON* for your input. Attached is what I finally came up with. Like I said, I didn't use the functions originaly posted because they were not working for me with the version of AutoIt I have.

tabs.au3

A little reading goes a long way. Post count means nothing.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...