Bert Posted December 18, 2005 Share Posted December 18, 2005 I designed a program that has 128 timers. It's layout is per my client's requirements. It works, but the processor time is around 70%. I have tried adding a sleep statement on line 410. It helped with the processor time, but it made the application sluggish. Anyone care to take a crack at fixing this one? expandcollapse popup#include <GUIConstants.au3> #include <Date.au3> AutoItSetOption ("TrayIconDebug", 1) ;TAB A Dim $Header_A = " Ticket" Dim $NameA, $TotalTimeA, $UnitA, $countA = 32 Dim $TimerActiveA_[50], $LabelA_[50], $TButtonA_[50], $SButtonA_[50], $InputA_[50]; $LabelA_[50] Dim $TimeA_[50], $TimerA_[50], $sTimeA_[50], $xkA, $ckA, $LeftA = 0, $TopA = 20, $XA Dim $InputA1_[50], $InputA2_[50] ;TAB B Dim $Header_B = " Ticket" Dim $NameB, $TotalTimeB, $UnitB, $countB = 32 Dim $TimerActiveB_[50], $LabelB_[50], $TButtonB_[50], $SButtonB_[50], $InputB_[50] , $LabelB_[50] Dim $TimeB_[50], $TimerB_[50], $sTimeB_[50], $xkB, $ckB, $LeftB = 0, $TopB = 20, $XB Dim $InputB1_[50], $InputB2_[50] ;TAB C Dim $Header_C = " Ticket" Dim $NameC, $TotalTimeC, $UnitC, $countC = 32 Dim $TimerActiveC_[50], $LabelC_[50], $TButtonC_[50], $SButtonC_[50], $InputC_[50] , $LabelC_[50] Dim $TimeC_[50], $TimerC_[50], $sTimeC_[50], $xkC, $ckC, $LeftC = 0, $TopC = 20, $XC Dim $InputC1_[50], $InputC2_[50] ;TAB D Dim $Header_D = " Ticket" Dim $NameD, $TotalTimeD, $UnitD, $countD = 32 Dim $TimerActiveD_[50], $LabelD_[50], $TButtonD_[50], $SButtonD_[50], $InputD_[50] , $LabelD_[50] Dim $TimeD_[50], $TimerD_[50], $sTimeD_[50], $xkD, $ckD, $LeftD = 0, $TopD = 20, $XD Dim $InputD1_[50], $InputD2_[50] AdlibEnable("AllTimers", 500) GUICreate(" T(egg) Timer", 871, 540,-1 ,-1 ) GUICtrlSetState(-1,$GUI_DISABLE) GUICtrlSetCursor(-1, 0) GUICtrlCreateTab (-1, -1, 895,540) ;FIRST TAB GUI------------------------------------------------------------------------------- GUICtrlCreateTabItem("Tickets 1-32") GUICtrlCreateLabel($Header_A & "s 1 - 32", -20, 23, 890, 18, $SS_CENTER, $WS_EX_STATICEDGE) GUICtrlSetFont(-1, 12, 700) GUICtrlSetBkColor(-1, 0xCEFFCE) For $XA = 1 To 8 ; row 1 GUICtrlCreateLabel($Header_A & " " & $XA, $LeftA, $TopA + 25, 80, 20, $SS_CENTER); ticket lable ex: ticket 1 $LabelA_[$XA] = GUICtrlCreateLabel("", $LeftA, $TopA + 43, 100, 30, 0x00800000 + 0x0001) $InputA1_[$XA] = GUICtrlCreateInput("", $LeftA + 80, $TopA + 23, 20, 18, 0x1000) GUICtrlSetFont($LabelA_[$XA], 16) GUICtrlSetData($LabelA_[$XA], "00:00:00") $TButtonA_[$XA] = GUICtrlCreateButton("Start", $LeftA, $TopA + 73, 50, 20) $SButtonA_[$XA] = GUICtrlCreateButton("Stop", $LeftA + 50, $TopA + 73, 50, 20) $InputA_[$XA] = GUICtrlCreateInput("", $LeftA, $TopA + 93, 100, 20,0x2000 + 0x1000 + 0x0002) $InputA2_[$XA] = GUICtrlCreateInput("", $LeftA, $TopA + 116, 100, 20, 0x1000 + 0x0002) ; row 2 GUICtrlCreateLabel($Header_A & " " & $XA + 8, $LeftA, $TopA + 150, 80, 20, $SS_CENTER) $LabelA_[$XA + 8] = GUICtrlCreateLabel("", $LeftA, $TopA + 170, 100, 30, 0x00800000 + 0x0001) $InputA1_[$XA +8] = GUICtrlCreateInput("", $LeftA + 80, $TopA + 150, 20, 18, 0x1000) GUICtrlSetFont($LabelA_[$XA + 8], 16) GUICtrlSetData($LabelA_[$XA + 8], "00:00:00") $TButtonA_[$XA + 8] = GUICtrlCreateButton("Start", $LeftA, $TopA + 200, 50, 20) $SButtonA_[$XA + 8] = GUICtrlCreateButton("Stop", $LeftA + 50, $TopA + 200, 50, 20) $InputA_[$XA + 8] = GUICtrlCreateInput("", $LeftA, $TopA + 220, 100, 20, 0x2000 + 0x1000 + 0x0002) $InputA2_[$XA + 8] = GUICtrlCreateInput("", $LeftA, $TopA + 243, 100, 20, 0x1000) ; row 3 GUICtrlCreateLabel($Header_A & " " & $XA + 16, $LeftA, $TopA + 275, 80, 20, $SS_CENTER) $LabelA_[$XA + 16] = GUICtrlCreateLabel("", $LeftA, $TopA + 295, 100, 30, 0x00800000 + 0x0001) $InputA1_[$XA +16] = GUICtrlCreateInput("", $LeftA + 80, $TopA + 275, 20, 18, 0x1000) GUICtrlSetFont($LabelA_[$XA + 16], 16) GUICtrlSetData($LabelA_[$XA + 16], "00:00:00") $TButtonA_[$XA + 16] = GUICtrlCreateButton("Start", $LeftA, $TopA + 325, 50, 20) $SButtonA_[$XA + 16] = GUICtrlCreateButton("Stop", $LeftA + 50, $TopA + 325, 50, 20) $InputA_[$XA + 16] = GUICtrlCreateInput("", $LeftA, $TopA + 345, 100, 20, 0x2000 + 0x1000 + 0x0002) $InputA2_[$XA + 16] = GUICtrlCreateInput("", $LeftA, $TopA + 368, 100, 20, 0x1000) ; row 4 GUICtrlCreateLabel($Header_A & " " & $XA + 24, $LeftA, $TopA + 400, 80, 20, $SS_CENTER) $LabelA_[$XA + 24] = GUICtrlCreateLabel("", $LeftA, $TopA + 420, 100, 30, 0x00800000 + 0x0001) $InputA1_[$XA +24] = GUICtrlCreateInput("", $LeftA + 80, $TopA + 400, 20, 18, 0x1000) GUICtrlSetFont($LabelA_[$XA + 24], 16) GUICtrlSetData($LabelA_[$XA + 24], "00:00:00") $TButtonA_[$XA + 24] = GUICtrlCreateButton("Start", $LeftA, $TopA + 450, 50, 20) $SButtonA_[$XA + 24] = GUICtrlCreateButton("Stop", $LeftA + 50, $TopA + 450, 50, 20) $InputA_[$XA + 24] = GUICtrlCreateInput("", $LeftA, $TopA + 470, 100, 20, 0x2000 + 0x1000 + 0x0002) $InputA2_[$XA + 24] = GUICtrlCreateInput("", $LeftA, $TopA + 493, 100, 20, 0x1000) $LeftA = $LeftA + 110 Next ;SECOND TAB GUI--------------------------------------------------------------------------------- GUICtrlCreateTabItem("Tickets 33 - 64") GUICtrlCreateLabel($Header_A & "s 33 thru 64", -20, 23, 890, 18, $SS_CENTER, $WS_EX_STATICEDGE) GUICtrlSetFont(-1, 12, 700) GUICtrlSetBkColor(-1, 0xa5fafe) For $XB = 1 To 8 ; row 1 TAB B GUICtrlCreateLabel($Header_B & " " & $XB + 32, $LeftB, $TopB + 25, 80, 20, $SS_CENTER); ticket lable ex: ticket 1 $LabelB_[$XB] = GUICtrlCreateLabel("", $LeftB, $TopB + 43, 100, 30, 0x00800000 + 0x0001) $InputB1_[$XB] = GUICtrlCreateInput("", $LeftB + 80, $TopB + 23, 20, 18, 0x1000) GUICtrlSetFont($LabelB_[$XB], 16) GUICtrlSetData($LabelB_[$XB], "00:00:00") $TButtonB_[$XB] = GUICtrlCreateButton("Start", $LeftB, $TopB + 73, 50, 20) $SButtonB_[$XB] = GUICtrlCreateButton("Stop", $LeftB + 50, $TopB + 73, 50, 20) $InputB_[$XB] = GUICtrlCreateInput("", $LeftB, $TopB + 93, 100, 20,0x2000 + 0x1000 + 0x0002) $InputB2_[$XB] = GUICtrlCreateInput("", $LeftB, $TopB + 116, 100, 20, 0x1000 + 0x0002) ; row 2 TAB B GUICtrlCreateLabel($Header_B & " " & $XB + 40, $LeftB, $TopB + 150, 80, 20, $SS_CENTER) $LabelB_[$XB + 8] = GUICtrlCreateLabel("", $LeftB, $TopB + 170, 100, 30, 0x00800000 + 0x0001) $InputB1_[$XB + 8] = GUICtrlCreateInput("", $LeftB + 80, $TopB + 150, 20, 18, 0x1000) GUICtrlSetFont($LabelB_[$XB + 8], 16) GUICtrlSetData($LabelB_[$XB + 8], "00:00:00") $TButtonB_[$XB + 8] = GUICtrlCreateButton("Start", $LeftB, $TopB + 200, 50, 20) $SButtonB_[$XB + 8] = GUICtrlCreateButton("Stop", $LeftB + 50, $TopB + 200, 50, 20) $InputB_[$XB + 8] = GUICtrlCreateInput("", $LeftB, $TopB + 220, 100, 20, 0x2000 + 0x1000 + 0x0002) $InputB2_[$XB + 8] = GUICtrlCreateInput("", $LeftB, $TopB + 243, 100, 20, 0x1000) ; row 3 TAB B GUICtrlCreateLabel($Header_B & " " & $XB + 48, $LeftB, $TopB + 275, 80, 20, $SS_CENTER) $LabelB_[$XB + 16] = GUICtrlCreateLabel("", $LeftB, $TopB + 295, 100, 30, 0x00800000 + 0x0001) $InputB1_[$XB +16] = GUICtrlCreateInput("", $LeftB + 80, $TopB + 275, 20, 18, 0x1000) GUICtrlSetFont($LabelB_[$XB + 16], 16) GUICtrlSetData($LabelB_[$XB + 16], "00:00:00") $TButtonB_[$XB + 16] = GUICtrlCreateButton("Start", $LeftB, $TopB + 325, 50, 20) $SButtonB_[$XB + 16] = GUICtrlCreateButton("Stop", $LeftB + 50, $TopB + 325, 50, 20) $InputB_[$XB + 16] = GUICtrlCreateInput("", $LeftB, $TopB + 345, 100, 20, 0x2000 + 0x1000 + 0x0002) $InputB2_[$XB + 16] = GUICtrlCreateInput("", $LeftB, $TopB + 368, 100, 20, 0x1000) ; row 4 TAB B GUICtrlCreateLabel($Header_B & " " & $XB + 56, $LeftB, $TopB + 400, 80, 20, $SS_CENTER) $LabelB_[$XB + 24] = GUICtrlCreateLabel("", $LeftB, $TopB + 420, 100, 30, 0x00800000 + 0x0001) $InputB1_[$XB + 24] = GUICtrlCreateInput("", $LeftB + 80, $TopB + 400, 20, 18, 0x1000) GUICtrlSetFont($LabelB_[$XB + 24], 16) GUICtrlSetData($LabelB_[$XB + 24], "00:00:00") $TButtonB_[$XB + 24] = GUICtrlCreateButton("Start", $LeftB, $TopB + 450, 50, 20) $SButtonB_[$XB + 24] = GUICtrlCreateButton("Stop", $LeftB + 50, $TopB + 450, 50, 20) $InputB_[$XB + 24] = GUICtrlCreateInput("", $LeftB, $TopB + 470, 100, 20, 0x2000 + 0x1000 + 0x0002) $InputB2_[$XB + 24] = GUICtrlCreateInput("", $LeftB, $TopB + 493, 100, 20, 0x1000) $LeftB = $LeftB + 110 Next ;THIRD TAB GUI---------------------------------------------------------------------------------- GUICtrlCreateTabItem("Tickets 65 - 96") GUICtrlCreateLabel($Header_C & "s 65 thru 96", -20, 23, 890, 18, $SS_CENTER, $WS_EX_STATICEDGE) GUICtrlSetFont(-1, 12, 700) GUICtrlSetBkColor(-1, 0xffd5d5) For $XC = 1 To 8 ; row 1 TAB C GUICtrlCreateLabel($Header_C & " " & $XC + 64, $LeftC, $TopC + 25, 80, 20, $SS_CENTER); ticket lable ex: ticket 1 $LabelC_[$XC] = GUICtrlCreateLabel("", $LeftC, $TopC + 43, 100, 30, 0x00800000 + 0x0001) $InputC1_[$XC] = GUICtrlCreateInput("", $LeftC + 80, $TopC + 23, 20, 18, 0x1000) GUICtrlSetFont($LabelC_[$XC], 16) GUICtrlSetData($LabelC_[$XC], "00:00:00") $TButtonC_[$XC] = GUICtrlCreateButton("Start", $LeftC, $TopC + 73, 50, 20) $SButtonC_[$XC] = GUICtrlCreateButton("Stop", $LeftC + 50, $TopC + 73, 50, 20) $InputC_[$XC] = GUICtrlCreateInput("", $LeftC, $TopC + 93, 100, 20,0x2000 + 0x1000 + 0x0002) $InputC2_[$XC] = GUICtrlCreateInput("", $LeftC, $TopC + 116, 100, 20, 0x1000 + 0x0002) ; row 2 TAB C GUICtrlCreateLabel($Header_C & " " & $XC + 72, $LeftC, $TopC + 150, 80, 20, $SS_CENTER) $LabelC_[$XC + 8] = GUICtrlCreateLabel("", $LeftC, $TopC + 170, 100, 30, 0x00800000 + 0x0001) $InputC1_[$XC + 8] = GUICtrlCreateInput("", $LeftC + 80, $TopC + 150, 20, 18, 0x1000) GUICtrlSetFont($LabelC_[$XC + 8], 16) GUICtrlSetData($LabelC_[$XC + 8], "00:00:00") $TButtonC_[$XC + 8] = GUICtrlCreateButton("Start", $LeftC, $TopC + 200, 50, 20) $SButtonC_[$XC + 8] = GUICtrlCreateButton("Stop", $LeftC + 50, $TopC + 200, 50, 20) $InputC_[$XC + 8] = GUICtrlCreateInput("", $LeftC, $TopC + 220, 100, 20, 0x2000 + 0x1000 + 0x0002) $InputC2_[$XC + 8] = GUICtrlCreateInput("", $LeftC, $TopC + 243, 100, 20, 0x1000) ; row 3 TAB C GUICtrlCreateLabel($Header_C & " " & $XC + 80, $LeftC, $TopC + 275, 80, 20, $SS_CENTER) $LabelC_[$XC + 16] = GUICtrlCreateLabel("", $LeftC, $TopC + 295, 100, 30, 0x00800000 + 0x0001) $InputC1_[$XC +16] = GUICtrlCreateInput("", $LeftC + 80, $TopC + 275, 20, 18, 0x1000) GUICtrlSetFont($LabelC_[$XC + 16], 16) GUICtrlSetData($LabelC_[$XC + 16], "00:00:00") $TButtonC_[$XC + 16] = GUICtrlCreateButton("Start", $LeftC, $TopC + 325, 50, 20) $SButtonC_[$XC + 16] = GUICtrlCreateButton("Stop", $LeftC + 50, $TopC + 325, 50, 20) $InputC_[$XC + 16] = GUICtrlCreateInput("", $LeftC, $TopC + 345, 100, 20, 0x2000 + 0x1000 + 0x0002) $InputC2_[$XC + 16] = GUICtrlCreateInput("", $LeftC, $TopC + 368, 100, 20, 0x1000) ; row 4 TAB C GUICtrlCreateLabel($Header_C & " " & $XC + 88, $LeftC, $TopC + 400, 80, 20, $SS_CENTER) $LabelC_[$XC + 24] = GUICtrlCreateLabel("", $LeftC, $TopC + 420, 100, 30, 0x00800000 + 0x0001) $InputC1_[$XC + 24] = GUICtrlCreateInput("", $LeftC + 80, $TopC + 400, 20, 18, 0x1000) GUICtrlSetFont($LabelC_[$XC + 24], 16) GUICtrlSetData($LabelC_[$XC + 24], "00:00:00") $TButtonC_[$XC + 24] = GUICtrlCreateButton("Start", $LeftC, $TopC + 450, 50, 20) $SButtonC_[$XC + 24] = GUICtrlCreateButton("Stop", $LeftC + 50, $TopC + 450, 50, 20) $InputC_[$XC + 24] = GUICtrlCreateInput("", $LeftC, $TopC + 470, 100, 20, 0x2000 + 0x1000 + 0x0002) $InputC2_[$XC + 24] = GUICtrlCreateInput("", $LeftC, $TopC + 493, 100, 20, 0x1000) $LeftC = $LeftC + 110 Next ;FORTH TAB GUI------------------------------------------------------------------------------------- GUICtrlCreateTabItem("Tickets 97 - 128") GUICtrlCreateLabel($Header_D & "s 97 thru 128", -20, 23, 890, 18, $SS_CENTER, $WS_EX_STATICEDGE) GUICtrlSetFont(-1, 12, 700) GUICtrlSetBkColor(-1, 0xF9C5FE) For $XD = 1 To 8 ; row 1 TAB D GUICtrlCreateLabel($Header_D & "" & $XD + 96, $LeftD, $TopD + 25, 80, 20, $SS_CENTER); ticket lable ex: ticket 1 $LabelD_[$XD] = GUICtrlCreateLabel("", $LeftD, $TopD + 43, 100, 30, 0x00800000 + 0x0001) $InputD1_[$XD] = GUICtrlCreateInput("", $LeftD + 80, $TopD + 23, 20, 18, 0x1000) GUICtrlSetFont($LabelD_[$XD], 16) GUICtrlSetData($LabelD_[$XD], "00:00:00") $TButtonD_[$XD] = GUICtrlCreateButton("Start", $LeftD, $TopD + 73, 50, 20) $SButtonD_[$XD] = GUICtrlCreateButton("Stop", $LeftD + 50, $TopD + 73, 50, 20) $InputD_[$XD] = GUICtrlCreateInput("", $LeftD, $TopD + 93, 100, 20,0x2000 + 0x1000 + 0x0002) $InputD2_[$XD] = GUICtrlCreateInput("", $LeftD, $TopD + 116, 100, 20, 0x1000 + 0x0002) ; row 2 TAB D GUICtrlCreateLabel($Header_D & " " & $XD + 104, $LeftD, $TopD + 150, 80, 20, $SS_CENTER) $LabelD_[$XD + 8] = GUICtrlCreateLabel("", $LeftD, $TopD + 170, 100, 30, 0x00800000 + 0x0001) $InputD1_[$XD + 8] = GUICtrlCreateInput("", $LeftD + 80, $TopD + 150, 20, 18, 0x1000) GUICtrlSetFont($LabelD_[$XD + 8], 16) GUICtrlSetData($LabelD_[$XD + 8], "00:00:00") $TButtonD_[$XD + 8] = GUICtrlCreateButton("Start", $LeftD, $TopD + 200, 50, 20) $SButtonD_[$XD + 8] = GUICtrlCreateButton("Stop", $LeftD + 50, $TopD + 200, 50, 20) $InputD_[$XD + 8] = GUICtrlCreateInput("", $LeftD, $TopD + 220, 100, 20, 0x2000 + 0x1000 + 0x0002) $InputD2_[$XD + 8] = GUICtrlCreateInput("", $LeftD, $TopD + 243, 100, 20, 0x1000) ; row 3 TAB D GUICtrlCreateLabel($Header_D & " " & $XD + 112, $LeftD, $TopD + 275, 80, 20, $SS_CENTER) $LabelD_[$XD + 16] = GUICtrlCreateLabel("", $LeftD, $TopD + 295, 100, 30, 0x00800000 + 0x0001) $InputD1_[$XD +16] = GUICtrlCreateInput("", $LeftD + 80, $TopD + 275, 20, 18, 0x1000) GUICtrlSetFont($LabelD_[$XD + 16], 16) GUICtrlSetData($LabelD_[$XD + 16], "00:00:00") $TButtonD_[$XD + 16] = GUICtrlCreateButton("Start", $LeftD, $TopD + 325, 50, 20) $SButtonD_[$XD + 16] = GUICtrlCreateButton("Stop", $LeftD + 50, $TopD + 325, 50, 20) $InputD_[$XD + 16] = GUICtrlCreateInput("", $LeftD, $TopD + 345, 100, 20, 0x2000 + 0x1000 + 0x0002) $InputD2_[$XD + 16] = GUICtrlCreateInput("", $LeftD, $TopD + 368, 100, 20, 0x1000) ; row 4 TAB D GUICtrlCreateLabel($Header_D & " " & $XD + 120, $LeftD, $TopD + 400, 80, 20, $SS_CENTER) $LabelD_[$XD + 24] = GUICtrlCreateLabel("", $LeftD, $TopD + 420, 100, 30, 0x00800000 + 0x0001) $InputD1_[$XD + 24] = GUICtrlCreateInput("", $LeftD + 80, $TopD + 400, 20, 18, 0x1000) GUICtrlSetFont($LabelD_[$XD + 24], 16) GUICtrlSetData($LabelD_[$XD + 24], "00:00:00") $TButtonD_[$XD + 24] = GUICtrlCreateButton("Start", $LeftD, $TopD + 450, 50, 20) $SButtonD_[$XD + 24] = GUICtrlCreateButton("Stop", $LeftD + 50, $TopD + 450, 50, 20) $InputD_[$XD + 24] = GUICtrlCreateInput("", $LeftD, $TopD + 470, 100, 20, 0x2000 + 0x1000 + 0x0002) $InputD2_[$XD + 24] = GUICtrlCreateInput("", $LeftD, $TopD + 493, 100, 20, 0x1000) $LeftD = $LeftD + 110 Next ;This section is for setting alarms and urgency levels. it will store settings in a INI file GUICtrlCreateTabItem("Options") GUICtrlCreateLabel("Urgency levels, notify messages", -20, 23, 890, 22, $SS_CENTER, $WS_EX_STATICEDGE) GUICtrlSetFont(-1, 12, 700) GUICtrlSetBkColor(-1, 0xB79B80) ;urgency 1 GUICtrlCreateGroup("Urgency level 1", 20, 50, 500, 100) GUICtrlCreateInput("", 30, 70, 18, 18) ;buttons $settingsA = GUICtrlCreateButton("Apply", 650, 500, 50, 20) $settingsB = GUICtrlCreateButton("Help", 720, 500, 50, 20) $settingsC = GUICtrlCreateButton("About", 790, 500, 50, 20) ;---------------------------------------------------------------------------------------------- GUISetState() While 1 $msg = GUIGetMsg() ;FIRST TAB CONTROLS For $xkA = 1 To $countA If $msg = $TButtonA_[$xkA] And GUICtrlRead($InputA_[$xkA]) > "" Then GUICtrlSetState($TButtonA_[$xkA], $GUI_DISABLE) GUICtrlSetState($InputA_[$xkA], $GUI_DISABLE) $TimerActiveA_[$xkA] = 1 If Not StringLen(String($TimerA_[$xkA])) Then $TimerA_[$xkA] = TimerInit() Else GUICtrlSetData($SButtonA_[$xkA], "Stop") EndIf ElseIf $msg = $TButtonA_[$xkA] Then MsgBox(64, "User Error", "Please Type in a Ticket Number ", 3) EndIf If $msg = $SButtonA_[$xkA] And GUICtrlRead($SButtonA_[$xkA]) = "Reset" Then GUICtrlSetData($LabelA_[$xkA], "00:00:00") GUICtrlSetData($InputA_[$xkA], "") GUICtrlSetData($SButtonA_[$xkA], "Stop") EndIf If $msg = $SButtonA_[$xkA] And GUICtrlRead($InputA_[$xkA]) <> "" And GUICtrlRead($SButtonA_[$xkA]) = "Stop" Then $TimerActiveA_[$xkA] = 0 GUICtrlSetData($SButtonA_[$xkA], "Reset") GUICtrlSetState($TButtonA_[$xkA], $GUI_ENABLE) GUICtrlSetState($InputA_[$xkA], $GUI_ENABLE) ; GUICtrlSetBkColor($LabelA_[$xkA], 0xD4D0C8) $NameA = GUICtrlRead($InputA_[$xkA]) ; If $xkA < 32 Then $UnitA = $Header_A & " " & $xkA EndIf EndIf If $xkA = 32 Then ExitLoop Next ;SECOND TAB CONTROLS---------------------------------------------------------------------------- For $xkB = 1 To $countB If $msg = $TButtonB_[$xkB] And GUICtrlRead($InputB_[$xkB]) > "" Then GUICtrlSetState($TButtonB_[$xkB], $GUI_DISABLE) GUICtrlSetState($InputB_[$xkB], $GUI_DISABLE) $TimerActiveB_[$xkB] = 1 If Not StringLen(String($TimerB_[$xkB])) Then $TimerB_[$xkB] = TimerInit() Else GUICtrlSetData($SButtonB_[$xkB], "Stop") EndIf ElseIf $msg = $TButtonB_[$xkB] Then MsgBox(64, "User Error", "Please Type in a Ticket Number ", 3) EndIf If $msg = $SButtonB_[$xkB] And GUICtrlRead($SButtonB_[$xkB]) = "Reset" Then GUICtrlSetData($LabelB_[$xkB], "00:00:00") GUICtrlSetData($InputB_[$xkB], "") GUICtrlSetData($SButtonB_[$xkB], "Stop") EndIf If $msg = $SButtonB_[$xkB] And GUICtrlRead($InputB_[$xkB]) <> "" And GUICtrlRead($SButtonB_[$xkB]) = "Stop" Then $TimerActiveB_[$xkB] = 0 GUICtrlSetData($SButtonB_[$xkB], "Reset") GUICtrlSetState($TButtonB_[$xkB], $GUI_ENABLE) GUICtrlSetState($InputB_[$xkB], $GUI_ENABLE) ; GUICtrlSetBkColor($LabelB_[$xkB], 0xD4D0C8) $NameB = GUICtrlRead($InputB_[$xkB]) ; If $xkB < 32 Then $UnitB = $Header_B & " " & $xkB EndIf EndIf If $xkB = 32 Then ExitLoop Next ;THIRD TAB CONTROLS----------------------------------------------------------------------------- For $xkC = 1 To $countC If $msg = $TButtonC_[$xkC] And GUICtrlRead($InputC_[$xkC]) > "" Then GUICtrlSetState($TButtonC_[$xkC], $GUI_DISABLE) GUICtrlSetState($InputC_[$xkC], $GUI_DISABLE) $TimerActiveC_[$xkC] = 1 If Not StringLen(String($TimerC_[$xkC])) Then $TimerC_[$xkC] = TimerInit() Else GUICtrlSetData($SButtonC_[$xkC], "Stop") EndIf ElseIf $msg = $TButtonC_[$xkC] Then MsgBox(64, "User Error", "Please Type in a Ticket Number ", 3) EndIf If $msg = $SButtonC_[$xkC] And GUICtrlRead($SButtonC_[$xkC]) = "Reset" Then GUICtrlSetData($LabelC_[$xkC], "00:00:00") GUICtrlSetData($InputC_[$xkC], "") GUICtrlSetData($SButtonC_[$xkC], "Stop") EndIf If $msg = $SButtonC_[$xkC] And GUICtrlRead($InputC_[$xkC]) <> "" And GUICtrlRead($SButtonC_[$xkC]) = "Stop" Then $TimerActiveC_[$xkC] = 0 GUICtrlSetData($SButtonC_[$xkC], "Reset") GUICtrlSetState($TButtonC_[$xkC], $GUI_ENABLE) GUICtrlSetState($InputC_[$xkC], $GUI_ENABLE) ; GUICtrlSetBkColor($LabelC_[$xkC], 0xD4D0C8) $NameB = GUICtrlRead($InputC_[$xkC]) ; If $xkC < 32 Then $UnitC = $Header_C & " " & $xkC EndIf EndIf If $xkC = 32 Then ExitLoop Next ;FORTH TAB CONTROLS------------------------------------------------------------------------------ For $xkD = 1 To $countD If $msg = $TButtonD_[$xkD] And GUICtrlRead($InputD_[$xkD]) > "" Then GUICtrlSetState($TButtonD_[$xkD], $GUI_DISABLE) GUICtrlSetState($InputD_[$xkD], $GUI_DISABLE) $TimerActiveD_[$xkD] = 1 If Not StringLen(String($TimerD_[$xkD])) Then $TimerD_[$xkD] = TimerInit() Else GUICtrlSetData($SButtonD_[$xkD], "Stop") EndIf ElseIf $msg = $TButtonD_[$xkD] Then MsgBox(64, "User Error", "Please Type in a Ticket Number ", 3) EndIf If $msg = $SButtonD_[$xkD] And GUICtrlRead($SButtonD_[$xkD]) = "Reset" Then GUICtrlSetData($LabelD_[$xkD], "00:00:00") GUICtrlSetData($InputD_[$xkD], "") GUICtrlSetData($SButtonD_[$xkD], "Stop") EndIf If $msg = $SButtond_[$xkD] And GUICtrlRead($InputD_[$xkD]) <> "" And GUICtrlRead($SButtonD_[$xkD]) = "Stop" Then $TimerActiveD_[$xkD] = 0 GUICtrlSetData($SButtonD_[$xkD], "Reset") GUICtrlSetState($TButtonD_[$xkD], $GUI_ENABLE) GUICtrlSetState($InputD_[$xkD], $GUI_ENABLE) ; GUICtrlSetBkColor($LabelD_[$xkD], 0xD4D0C8) $NameB = GUICtrlRead($InputD_[$xkD]) ; If $xkD < 32 Then $UnitD = $Header_D & " " & $xkD EndIf EndIf If $xkD = 32 Then ExitLoop Next ;--------------------------------------------------------------------------------------------- If $msg = $GUI_EVENT_CLOSE Then ExitLoop ; SLEEP(100) ; Improves processor time, GUI responce time is much slower however. WEnd Func AllTimers() Local $Secs, $Mins, $Hour ;first tab For $ckA = 1 To $countA If $TimerActiveA_[$ckA] Then _TicksToTime(Int(TimerDiff($TimerA_[$ckA])), $Hour, $Mins, $Secs) $TimeA_[$ckA] = StringFormat("%02i:%02i:%02i", $Hour, $Mins, $Secs) If $sTimeA_[$ckA] <> $TimeA_[$ckA] Then GUICtrlSetData($LabelA_[$ckA], $TimeA_[$ckA]) If $Mins == 0 and $Secs == 05 Then; for testing GUICtrlSetBkColor($LabelA_[$ckA], 0xFFFF00 );for testing msgbox(0, "5 seconds", "5 seconds");for testing endif If $Mins == 0 and $Secs == 10 Then;for testing GUICtrlSetBkColor($LabelA_[$ckA], 0xF5C636);for testing msgbox(0, "10 seconds", "10 seconds");for testing endif If $Mins == 0 and $Secs == 15 Then;for testing GUICtrlSetBkColor($LabelA_[$ckA], 0xFF0000);for testing msgbox(0, "15 seconds", "15 seconds");for testing endif EndIf Next ;second tab For $ckB = 1 To $countB If $TimerActiveB_[$ckB] Then _TicksToTime(Int(TimerDiff($TimerB_[$ckB])), $Hour, $Mins, $Secs) $TimeB_[$ckB] = StringFormat("%02i:%02i:%02i", $Hour, $Mins, $Secs) If $sTimeB_[$ckB] <> $TimeB_[$ckB] Then GUICtrlSetData($LabelB_[$ckB], $TimeB_[$ckB]) EndIf Next ;THIRD TIMER For $ckC = 1 To $countC If $TimerActiveC_[$ckC] Then _TicksToTime(Int(TimerDiff($TimerC_[$ckC])), $Hour, $Mins, $Secs) $TimeC_[$ckC] = StringFormat("%02i:%02i:%02i", $Hour, $Mins, $Secs) If $sTimeC_[$ckC] <> $TimeC_[$ckC] Then GUICtrlSetData($LabelC_[$ckC], $TimeC_[$ckC]) EndIf Next ;FORTH TIMER For $ckD = 1 To $countD If $TimerActiveD_[$ckD] Then _TicksToTime(Int(TimerDiff($TimerD_[$ckD])), $Hour, $Mins, $Secs) $TimeD_[$ckD] = StringFormat("%02i:%02i:%02i", $Hour, $Mins, $Secs) If $sTimeD_[$ckD] <> $TimeD_[$ckD] Then GUICtrlSetData($LabelD_[$ckD], $TimeD_[$ckD]) EndIf Next EndFunc;==>AllTimers The Vollatran project  My blog: http://www.vollysinterestingshit.com/ Link to comment Share on other sites More sharing options...
erebus Posted December 18, 2005 Share Posted December 18, 2005 It's really foolish to wait from someone to debug 500 lines of code for you (no offense). Since you understand that the problem resides on the Sleep() function, why don't you try by adding several Sleeps() in your code and see which is the specific part that cause the CPU problem? You only need some research here, not a coding opinion. Link to comment Share on other sites More sharing options...
Developers Jos Posted December 18, 2005 Developers Share Posted December 18, 2005 try replace your while loop with this one: expandcollapse popupWhile 1 $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then ExitLoop IF $msg < 1 then ContinueLoop Switch GUICtrlRead($h_tab) Case 0 For $xkA = 1 To $countA If $msg = $TButtonA_[$xkA] And GUICtrlRead($InputA_[$xkA]) > "" Then GUICtrlSetState($TButtonA_[$xkA], $GUI_DISABLE) GUICtrlSetState($InputA_[$xkA], $GUI_DISABLE) $TimerActiveA_[$xkA] = 1 If Not StringLen(String($TimerA_[$xkA])) Then $TimerA_[$xkA] = TimerInit() Else GUICtrlSetData($SButtonA_[$xkA], "Stop") EndIf ElseIf $msg = $TButtonA_[$xkA] Then MsgBox(64, "User Error", "Please Type in a Ticket Number ", 3) EndIf If $msg = $SButtonA_[$xkA] And GUICtrlRead($SButtonA_[$xkA]) = "Reset" Then GUICtrlSetData($LabelA_[$xkA], "00:00:00") GUICtrlSetData($InputA_[$xkA], "") GUICtrlSetData($SButtonA_[$xkA], "Stop") EndIf If $msg = $SButtonA_[$xkA] And GUICtrlRead($InputA_[$xkA]) <> "" And GUICtrlRead($SButtonA_[$xkA]) = "Stop" Then $TimerActiveA_[$xkA] = 0 GUICtrlSetData($SButtonA_[$xkA], "Reset") GUICtrlSetState($TButtonA_[$xkA], $GUI_ENABLE) GUICtrlSetState($InputA_[$xkA], $GUI_ENABLE) ; GUICtrlSetBkColor($LabelA_[$xkA], 0xD4D0C8) $NameA = GUICtrlRead($InputA_[$xkA]) ; If $xkA < 32 Then $UnitA = $Header_A & " " & $xkA EndIf EndIf If $xkA = 32 Then ExitLoop Next Case 1 ;SECOND TAB CONTROLS---------------------------------------------------------------------------- For $xkB = 1 To $countB If $msg = $TButtonB_[$xkB] And GUICtrlRead($InputB_[$xkB]) > "" Then GUICtrlSetState($TButtonB_[$xkB], $GUI_DISABLE) GUICtrlSetState($InputB_[$xkB], $GUI_DISABLE) $TimerActiveB_[$xkB] = 1 If Not StringLen(String($TimerB_[$xkB])) Then $TimerB_[$xkB] = TimerInit() Else GUICtrlSetData($SButtonB_[$xkB], "Stop") EndIf ElseIf $msg = $TButtonB_[$xkB] Then MsgBox(64, "User Error", "Please Type in a Ticket Number ", 3) EndIf If $msg = $SButtonB_[$xkB] And GUICtrlRead($SButtonB_[$xkB]) = "Reset" Then GUICtrlSetData($LabelB_[$xkB], "00:00:00") GUICtrlSetData($InputB_[$xkB], "") GUICtrlSetData($SButtonB_[$xkB], "Stop") EndIf If $msg = $SButtonB_[$xkB] And GUICtrlRead($InputB_[$xkB]) <> "" And GUICtrlRead($SButtonB_[$xkB]) = "Stop" Then $TimerActiveB_[$xkB] = 0 GUICtrlSetData($SButtonB_[$xkB], "Reset") GUICtrlSetState($TButtonB_[$xkB], $GUI_ENABLE) GUICtrlSetState($InputB_[$xkB], $GUI_ENABLE) ; GUICtrlSetBkColor($LabelB_[$xkB], 0xD4D0C8) $NameB = GUICtrlRead($InputB_[$xkB]) ; If $xkB < 32 Then $UnitB = $Header_B & " " & $xkB EndIf EndIf If $xkB = 32 Then ExitLoop Next Case 2 ;THIRD TAB CONTROLS----------------------------------------------------------------------------- For $xkC = 1 To $countC If $msg = $TButtonC_[$xkC] And GUICtrlRead($InputC_[$xkC]) > "" Then GUICtrlSetState($TButtonC_[$xkC], $GUI_DISABLE) GUICtrlSetState($InputC_[$xkC], $GUI_DISABLE) $TimerActiveC_[$xkC] = 1 If Not StringLen(String($TimerC_[$xkC])) Then $TimerC_[$xkC] = TimerInit() Else GUICtrlSetData($SButtonC_[$xkC], "Stop") EndIf ElseIf $msg = $TButtonC_[$xkC] Then MsgBox(64, "User Error", "Please Type in a Ticket Number ", 3) EndIf If $msg = $SButtonC_[$xkC] And GUICtrlRead($SButtonC_[$xkC]) = "Reset" Then GUICtrlSetData($LabelC_[$xkC], "00:00:00") GUICtrlSetData($InputC_[$xkC], "") GUICtrlSetData($SButtonC_[$xkC], "Stop") EndIf If $msg = $SButtonC_[$xkC] And GUICtrlRead($InputC_[$xkC]) <> "" And GUICtrlRead($SButtonC_[$xkC]) = "Stop" Then $TimerActiveC_[$xkC] = 0 GUICtrlSetData($SButtonC_[$xkC], "Reset") GUICtrlSetState($TButtonC_[$xkC], $GUI_ENABLE) GUICtrlSetState($InputC_[$xkC], $GUI_ENABLE) ; GUICtrlSetBkColor($LabelC_[$xkC], 0xD4D0C8) $NameB = GUICtrlRead($InputC_[$xkC]) ; If $xkC < 32 Then $UnitC = $Header_C & " " & $xkC EndIf EndIf If $xkC = 32 Then ExitLoop Next Case 3 ;FORTH TAB CONTROLS------------------------------------------------------------------------------ For $xkD = 1 To $countD If $msg = $TButtonD_[$xkD] And GUICtrlRead($InputD_[$xkD]) > "" Then GUICtrlSetState($TButtonD_[$xkD], $GUI_DISABLE) GUICtrlSetState($InputD_[$xkD], $GUI_DISABLE) $TimerActiveD_[$xkD] = 1 If Not StringLen(String($TimerD_[$xkD])) Then $TimerD_[$xkD] = TimerInit() Else GUICtrlSetData($SButtonD_[$xkD], "Stop") EndIf ElseIf $msg = $TButtonD_[$xkD] Then MsgBox(64, "User Error", "Please Type in a Ticket Number ", 3) EndIf If $msg = $SButtonD_[$xkD] And GUICtrlRead($SButtonD_[$xkD]) = "Reset" Then GUICtrlSetData($LabelD_[$xkD], "00:00:00") GUICtrlSetData($InputD_[$xkD], "") GUICtrlSetData($SButtonD_[$xkD], "Stop") EndIf If $msg = $SButtonD_[$xkD] And GUICtrlRead($InputD_[$xkD]) <> "" And GUICtrlRead($SButtonD_[$xkD]) = "Stop" Then $TimerActiveD_[$xkD] = 0 GUICtrlSetData($SButtonD_[$xkD], "Reset") GUICtrlSetState($TButtonD_[$xkD], $GUI_ENABLE) GUICtrlSetState($InputD_[$xkD], $GUI_ENABLE) ; GUICtrlSetBkColor($LabelD_[$xkD], 0xD4D0C8) $NameB = GUICtrlRead($InputD_[$xkD]) ; If $xkD < 32 Then $UnitD = $Header_D & " " & $xkD EndIf EndIf If $xkD = 32 Then ExitLoop Next EndSwitch ;--------------------------------------------------------------------------------------------- ; SLEEP(100); Improves processor time, GUI responce time is much slower however. WEnd SciTE4AutoIt3 Full installer Download page  - Beta files    Read before posting   How to post scriptsource   Forum etiquette Forum Rules  Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
Bert Posted December 18, 2005 Author Share Posted December 18, 2005 It's really foolish to wait from someone to debug 500 lines of code for you (no offense).Since you understand that the problem resides on the Sleep() function, why don't you try by adding several Sleeps() in your code and see which is the specific part that cause the CPU problem?You only need some research here, not a coding opinion.Your right, normally I try only to provide a example of the problem. In this case, I didn't have a alternative, and I don't have the skill (yet) to debug it effectively. In the past, I had one other program that had this type of problem, and adding a sleep statement fixed it. When I tried to do the same to this script, it failed. I posted the entire script for I don't have the experience to troubleshoot this problem. The Vollatran project  My blog: http://www.vollysinterestingshit.com/ Link to comment Share on other sites More sharing options...
Bert Posted December 18, 2005 Author Share Posted December 18, 2005 I plugged in your fix, and I get a error on line 273. Not being declared Switch GUICtrlRead($h_tab) What does $h_tab need to reference? The Vollatran project  My blog: http://www.vollysinterestingshit.com/ Link to comment Share on other sites More sharing options...
Developers Jos Posted December 18, 2005 Developers Share Posted December 18, 2005 (edited) I plugged in your fix, and I get a error on line 273. Not being declared Switch GUICtrlRead($h_tab) What does $h_tab need to reference?sorry about that.... it is used to check which tab is active, because there is no need to update the other tabs....change: GUICtrlCreateTab (-1, -1, 895,540) to $h_tab = GUICtrlCreateTab (-1, -1, 895,540) Edited December 18, 2005 by JdeB SciTE4AutoIt3 Full installer Download page  - Beta files    Read before posting   How to post scriptsource   Forum etiquette Forum Rules  Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
Bert Posted December 18, 2005 Author Share Posted December 18, 2005 I just figured it out. I had it reference line 34: $h_tab = GUICtrlCreateTab (-1, -1, 895,540) works perfectly. THANK YOU SO MUCH! The Vollatran project  My blog: http://www.vollysinterestingshit.com/ Link to comment Share on other sites More sharing options...
Developers Jos Posted December 18, 2005 Developers Share Posted December 18, 2005 I just figured it out. I had it reference line 34: $h_tab = GUICtrlCreateTab (-1, -1, 895,540) works perfectly. THANK YOU SO MUCH! See my previous answer for an explanation... by the way, the biggest process time saver is this : IF $msg < 1 then ContinueLoop SciTE4AutoIt3 Full installer Download page  - Beta files    Read before posting   How to post scriptsource   Forum etiquette Forum Rules  Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now