Jump to content

Flashes of graphics


Go to solution Solved by Lepes,

Recommended Posts

Hi all,

I have a window with many labels and combobox. When we click on the start button, many checks are made on the consistency of hours.

This check flashes all labels and combobox. Because if there is an error a graphic form turns red. We must correct hours of the combobox, click the "start" button again to check.

Is it possible to change the code to avoid this flashes ? 

#include <File.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <Date.au3>
#include <ComboConstants.au3>

Window()
Func Window()
    Local $h_GUI = GUICreate("Automat Counting", 672, 400, -1, -1)

    GUISetFont(10)
    Local $a_WindowClientArea_Size = WinGetClientSize($h_GUI) ;$a_WindowClientArea_Size[0] = Width, $a_WindowClientArea_Size[1] = Height
    Local $a_Hours[25] = [" -", "00", "01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23"]
    Local Const $a_Days[7] = ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"]
    Local Const $a_Times[3] = ["Morning", "Day", "Night"]

    GUICtrlCreateGroup("Days", 10, 10, $a_WindowClientArea_Size[0] - 20, 317)
    GUICtrlCreateGroup("", 108, 35, 168, 282)
    GUICtrlCreateLabel("Morning", 108, 43, 168, 24, BitOR($SS_CENTERIMAGE, $SS_CENTER))
    GUICtrlSetColor(-1, 0x003e51)
    GUICtrlSetBkColor(-1, 0x00c4ba)
    GUICtrlCreateGroup("", 296, 35, 168, 282)
    GUICtrlCreateLabel("Day", 296, 43, 168, 24, BitOR($SS_CENTERIMAGE, $SS_CENTER))
    GUICtrlSetColor(-1, 0x003e51)
    GUICtrlSetBkColor(-1, 0x00c4ba)
    GUICtrlCreateGroup("", 484, 35, 168, 282)
    GUICtrlCreateLabel("Night", 484, 43, 168, 24, BitOR($SS_CENTERIMAGE, $SS_CENTER))
    GUICtrlSetColor(-1, 0x003e51)
    GUICtrlSetBkColor(-1, 0x00c4ba)

    $s_Days = 79
    $s_Entre_Times = 118
    $s_Et_Times = 207
    For $a_Time = 0 To UBound($a_Times) -1
        For $a_Day = 0 To UBound($a_Days) -1
            GUICtrlCreateLabel("Start", $s_Entre_Times, $s_Days, 39, 24, $SS_CENTERIMAGE)
            GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
            GUICtrlCreateLabel("->", $s_Et_Times, $s_Days, 19, 24, $SS_CENTERIMAGE)
            GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
            $s_Days += 34
        Next
        $s_Entre_Times += 188
        $s_Et_Times += 188
        $s_Days = 79
    Next

    Global $id_Monday = GUICtrlCreateCheckbox("Monday", 20, 79, 78, 24)
    GUICtrlSetState(-1, $GUI_CHECKED)
    Global $id_Monday_Start_Morning = GUICtrlCreateCombo("", 157, 79, 40, 24, $CBS_DROPDOWNLIST)
    GUICtrlSetData($id_Monday_Start_Morning, _ArrayToString($a_Hours), " -")
    Global $id_Monday_End_Morning = GUICtrlCreateCombo("", 226, 79, 40, 24, $CBS_DROPDOWNLIST)
    GUICtrlSetData($id_Monday_End_Morning, _ArrayToString($a_Hours), " -")
    Global $id_Monday_Start_Day = GUICtrlCreateCombo("", 345, 79, 40, 24, $CBS_DROPDOWNLIST)
    GUICtrlSetData($id_Monday_Start_Day, _ArrayToString($a_Hours), " -")
    Global $id_Monday_End_Day = GUICtrlCreateCombo("", 414, 79, 40, 24, $CBS_DROPDOWNLIST)
    GUICtrlSetData($id_Monday_End_Day, _ArrayToString($a_Hours), " -")
    Global $id_Monday_Start_Night = GUICtrlCreateCombo("", 533, 79, 40, 24, $CBS_DROPDOWNLIST)
    GUICtrlSetData($id_Monday_Start_Night, _ArrayToString($a_Hours), " -")
    Global $id_Monday_End_Night = GUICtrlCreateCombo("", 602, 79, 40, 24, $CBS_DROPDOWNLIST)
    GUICtrlSetData($id_Monday_End_Night, _ArrayToString($a_Hours), " -")

    Global $id_Tuesday = GUICtrlCreateCheckbox("Tuesday", 20, 113, 78, 24)
    GUICtrlSetState(-1, $GUI_CHECKED)
    Global $id_Tuesday_Start_Morning = GUICtrlCreateCombo("", 157, 113, 40, 24, $CBS_DROPDOWNLIST)
    GUICtrlSetData($id_Tuesday_Start_Morning, _ArrayToString($a_Hours), " -")
    Global $id_Tuesday_End_Morning = GUICtrlCreateCombo("", 226, 113, 40, 24, $CBS_DROPDOWNLIST)
    GUICtrlSetData($id_Tuesday_End_Morning, _ArrayToString($a_Hours), " -")

    Global $id_Tuesday_Start_Day = GUICtrlCreateCombo("", 345, 113, 40, 24, $CBS_DROPDOWNLIST)
    GUICtrlSetData($id_Tuesday_Start_Day, _ArrayToString($a_Hours), " -")
    Global $id_Tuesday_End_Day = GUICtrlCreateCombo("", 414, 113, 40, 24, $CBS_DROPDOWNLIST)
    GUICtrlSetData($id_Tuesday_End_Day, _ArrayToString($a_Hours), " -")

    Global $id_Tuesday_Start_Night = GUICtrlCreateCombo("", 533, 113, 40, 24, $CBS_DROPDOWNLIST)
    GUICtrlSetData($id_Tuesday_Start_Night, _ArrayToString($a_Hours), " -")
    Global $id_Tuesday_End_Night = GUICtrlCreateCombo("", 602, 113, 40, 24, $CBS_DROPDOWNLIST)
    GUICtrlSetData($id_Tuesday_End_Night, _ArrayToString($a_Hours), " -")

    Global $id_Wednesday = GUICtrlCreateCheckbox("Wednesday", 20, 147, 78, 24)
    GUICtrlSetState(-1, $GUI_CHECKED)
    Global $id_Wednesday_Start_Morning = GUICtrlCreateCombo("", 157, 147, 40, 24, $CBS_DROPDOWNLIST)
    GUICtrlSetData($id_Wednesday_Start_Morning, _ArrayToString($a_Hours), " -")
    Global $id_Wednesday_End_Morning = GUICtrlCreateCombo("", 226, 147, 40, 24, $CBS_DROPDOWNLIST)
    GUICtrlSetData($id_Wednesday_End_Morning, _ArrayToString($a_Hours), " -")
    Global $id_Wednesday_Start_Day = GUICtrlCreateCombo("", 345, 147, 40, 24, $CBS_DROPDOWNLIST)
    GUICtrlSetData($id_Wednesday_Start_Day, _ArrayToString($a_Hours), " -")
    Global $id_Wednesday_End_Day = GUICtrlCreateCombo("", 414, 147, 40, 24, $CBS_DROPDOWNLIST)
    GUICtrlSetData($id_Wednesday_End_Day, _ArrayToString($a_Hours), " -")
    Global $id_Wednesday_Start_Night = GUICtrlCreateCombo("", 533, 147, 40, 24, $CBS_DROPDOWNLIST)
    GUICtrlSetData($id_Wednesday_Start_Night, _ArrayToString($a_Hours), " -")
    Global $id_Wednesday_End_Night = GUICtrlCreateCombo("", 602, 147, 40, 24, $CBS_DROPDOWNLIST)
    GUICtrlSetData($id_Wednesday_End_Night, _ArrayToString($a_Hours), " -")

    Global $id_Thursday = GUICtrlCreateCheckbox("Tuesday", 20, 181, 78, 24)
    GUICtrlSetState(-1, $GUI_CHECKED)
    Global $id_Thursday_Start_Morning = GUICtrlCreateCombo("", 157, 181, 40, 24, $CBS_DROPDOWNLIST)
    GUICtrlSetData($id_Thursday_Start_Morning, _ArrayToString($a_Hours), " -")
    Global $id_Thursday_End_Morning = GUICtrlCreateCombo("", 226, 181, 40, 24, $CBS_DROPDOWNLIST)
    GUICtrlSetData($id_Thursday_End_Morning, _ArrayToString($a_Hours), " -")
    Global $id_Thursday_Start_Day = GUICtrlCreateCombo("", 345, 181, 40, 24, $CBS_DROPDOWNLIST)
    GUICtrlSetData($id_Thursday_Start_Day, _ArrayToString($a_Hours), " -")
    Global $id_Thursday_End_Day = GUICtrlCreateCombo("", 414, 181, 40, 24, $CBS_DROPDOWNLIST)
    GUICtrlSetData($id_Thursday_End_Day, _ArrayToString($a_Hours), " -")
    Global $id_Thursday_Start_Night = GUICtrlCreateCombo("", 533, 181, 40, 24, $CBS_DROPDOWNLIST)
    GUICtrlSetData($id_Thursday_Start_Night, _ArrayToString($a_Hours), " -")
    Global $id_Thursday_End_Night = GUICtrlCreateCombo("", 602, 181, 40, 24, $CBS_DROPDOWNLIST)
    GUICtrlSetData($id_Thursday_End_Night, _ArrayToString($a_Hours), " -")
    Global $id_Friday = GUICtrlCreateCheckbox("Friday", 20, 215, 78, 24)
    GUICtrlSetState(-1, $GUI_CHECKED)
    Global $id_Friday_Start_Morning = GUICtrlCreateCombo("", 157, 215, 40, 24, $CBS_DROPDOWNLIST)
    GUICtrlSetData($id_Friday_Start_Morning, _ArrayToString($a_Hours), " -")
    Global $id_Friday_End_Morning = GUICtrlCreateCombo("", 226, 215, 40, 24, $CBS_DROPDOWNLIST)
    GUICtrlSetData($id_Friday_End_Morning, _ArrayToString($a_Hours), " -")
    Global $id_Friday_Start_Day = GUICtrlCreateCombo("", 345, 215, 40, 24, $CBS_DROPDOWNLIST)
    GUICtrlSetData($id_Friday_Start_Day, _ArrayToString($a_Hours), " -")
    Global $id_Friday_End_Day = GUICtrlCreateCombo("", 414, 215, 40, 24, $CBS_DROPDOWNLIST)
    GUICtrlSetData($id_Friday_End_Day, _ArrayToString($a_Hours), " -")
    Global $id_Friday_Start_Night = GUICtrlCreateCombo("", 533, 215, 40, 24, $CBS_DROPDOWNLIST)
    GUICtrlSetData($id_Friday_Start_Night, _ArrayToString($a_Hours), " -")
    Global $id_Friday_End_Night = GUICtrlCreateCombo("", 602, 215, 40, 24, $CBS_DROPDOWNLIST)
    GUICtrlSetData($id_Friday_End_Night, _ArrayToString($a_Hours), " -")

    Global $id_Saturday = GUICtrlCreateCheckbox("Saturday", 20, 249, 78, 24)
    GUICtrlSetState(-1, $GUI_CHECKED)
    Global $id_Saturday_Start_Morning = GUICtrlCreateCombo("", 157, 249, 40, 24, $CBS_DROPDOWNLIST)
    GUICtrlSetData($id_Saturday_Start_Morning, _ArrayToString($a_Hours), " -")
    Global $id_Saturday_End_Morning = GUICtrlCreateCombo("", 226, 249, 40, 24, $CBS_DROPDOWNLIST)
    GUICtrlSetData($id_Saturday_End_Morning, _ArrayToString($a_Hours), " -")

    Global $id_Saturday_Start_Day = GUICtrlCreateCombo("", 345, 249, 40, 24, $CBS_DROPDOWNLIST)
    GUICtrlSetData($id_Saturday_Start_Day, _ArrayToString($a_Hours), " -")
    Global $id_Saturday_End_Day = GUICtrlCreateCombo("", 414, 249, 40, 24, $CBS_DROPDOWNLIST)
    GUICtrlSetData($id_Saturday_End_Day, _ArrayToString($a_Hours), " -")

    Global $id_Saturday_Start_Night = GUICtrlCreateCombo("", 533, 249, 40, 24, $CBS_DROPDOWNLIST)
    GUICtrlSetData($id_Saturday_Start_Night, _ArrayToString($a_Hours), " -")
    Global $id_Saturday_End_Night = GUICtrlCreateCombo("", 602, 249, 40, 24, $CBS_DROPDOWNLIST)
    GUICtrlSetData($id_Saturday_End_Night, _ArrayToString($a_Hours), " -")

    Global $id_Sunday = GUICtrlCreateCheckbox("Sunday", 20, 283, 78, 24)
    GUICtrlSetState(-1, $GUI_CHECKED)
    Global $id_Sunday_Start_Morning = GUICtrlCreateCombo("", 157, 283, 40, 24, $CBS_DROPDOWNLIST)
    GUICtrlSetData($id_Sunday_Start_Morning, _ArrayToString($a_Hours), " -")
    Global $id_Sunday_End_Morning = GUICtrlCreateCombo("", 226, 283, 40, 24, $CBS_DROPDOWNLIST)
    GUICtrlSetData($id_Sunday_End_Morning, _ArrayToString($a_Hours), " -")
    Global $id_Sunday_Start_Day = GUICtrlCreateCombo("", 345, 283, 40, 24, $CBS_DROPDOWNLIST)
    GUICtrlSetData($id_Sunday_Start_Day, _ArrayToString($a_Hours), " -")
    Global $id_Sunday_End_Day = GUICtrlCreateCombo("", 414, 283, 40, 24, $CBS_DROPDOWNLIST)
    GUICtrlSetData($id_Sunday_End_Day, _ArrayToString($a_Hours), " -")
    Global $id_Sunday_Start_Night = GUICtrlCreateCombo("", 533, 283, 40, 24, $CBS_DROPDOWNLIST)
    GUICtrlSetData($id_Sunday_Start_Night, _ArrayToString($a_Hours), " -")
    Global $id_Sunday_End_Night = GUICtrlCreateCombo("", 602, 283, 40, 24, $CBS_DROPDOWNLIST)
    GUICtrlSetData($id_Sunday_End_Night, _ArrayToString($a_Hours), " -")

    $id_Launch = GUICtrlCreateButton("Start", $a_WindowClientArea_Size[0] / 2 - 100, $a_WindowClientArea_Size[1] - 35, 200, 25)

    ; Red zones
    $g_Monday_Morning = GUICtrlCreateGraphic(113, 77, 158, 28)
    $g_Monday_Day = GUICtrlCreateGraphic(301, 77, 158, 28)
    $g_Monday_Night = GUICtrlCreateGraphic(489, 77, 158, 28)
    $g_Tuesday_Morning = GUICtrlCreateGraphic(113, 111, 158, 28)
    $g_Tuesday_Day = GUICtrlCreateGraphic(301, 111, 158, 28)
    $g_Tuesday_Night = GUICtrlCreateGraphic(489, 111, 158, 28)
    $g_Wednesday_Morning = GUICtrlCreateGraphic(113, 145, 158, 28)
    $g_Wednesday_Day = GUICtrlCreateGraphic(301, 145, 158, 28)
    $g_Wednesday_Night = GUICtrlCreateGraphic(489, 145, 158, 28)
    $g_Thursday_Morning = GUICtrlCreateGraphic(113, 179, 158, 28)
    $g_Thursday_Day = GUICtrlCreateGraphic(301, 179, 158, 28)
    $g_Thursday_Night = GUICtrlCreateGraphic(489, 179, 158, 28)
    $g_Friday_Morning = GUICtrlCreateGraphic(113, 213, 158, 28)
    $g_Friday_Day = GUICtrlCreateGraphic(301, 213, 158, 28)
    $g_Friday_Night = GUICtrlCreateGraphic(489, 213, 158, 28)
    $g_Saturday_Morning = GUICtrlCreateGraphic(113, 247, 158, 28)
    $g_Saturday_Day = GUICtrlCreateGraphic(301, 247, 158, 28)
    $g_Saturday_Night = GUICtrlCreateGraphic(489, 247, 158, 28)
    $g_Sunday_Morning = GUICtrlCreateGraphic(113, 281, 158, 28)
    $g_Sunday_Day = GUICtrlCreateGraphic(301, 281, 158, 28)
    $g_Sunday_Night = GUICtrlCreateGraphic(489, 281, 158, 28)

    GUISetState(@SW_SHOW, $h_GUI)

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop
            Case $id_Launch
                Local $b_ComboError = 0

                Global $s_Monday_Start_Morning = GUICtrlRead($id_Monday_Start_Morning) ; >>>>>>>>>> Monday
                Global $s_Monday_End_Morning = GUICtrlRead($id_Monday_End_Morning)
                Global $s_Monday_Start_Day = GUICtrlRead($id_Monday_Start_Day)
                Global $s_Monday_End_Day = GUICtrlRead($id_Monday_End_Day)
                Global $s_Monday_Start_Night = GUICtrlRead($id_Monday_Start_Night)
                Global $s_Monday_End_Night = GUICtrlRead($id_Monday_End_Night)
                Global $s_Tuesday_Start_Morning = GUICtrlRead($id_Tuesday_Start_Morning) ; >>>>>>>>>> Tuesday
                Global $s_Tuesday_End_Morning = GUICtrlRead($id_Tuesday_End_Morning)
                Global $s_Tuesday_Start_Day = GUICtrlRead($id_Tuesday_Start_Day)
                Global $s_Tuesday_End_Day = GUICtrlRead($id_Tuesday_End_Day)
                Global $s_Tuesday_Start_Night = GUICtrlRead($id_Tuesday_Start_Night)
                Global $s_Tuesday_End_Night = GUICtrlRead($id_Tuesday_End_Night)
                Global $s_Wednesday_Start_Morning = GUICtrlRead($id_Wednesday_Start_Morning) ; >>>>>>>>>> Wednesday
                Global $s_Wednesday_End_Morning = GUICtrlRead($id_Wednesday_End_Morning)
                Global $s_Wednesday_Start_Day = GUICtrlRead($id_Wednesday_Start_Day)
                Global $s_Wednesday_End_Day = GUICtrlRead($id_Wednesday_End_Day)
                Global $s_Wednesday_Start_Night = GUICtrlRead($id_Wednesday_Start_Night)
                Global $s_Wednesday_End_Night = GUICtrlRead($id_Wednesday_End_Night)
                Global $s_Thursday_Start_Morning = GUICtrlRead($id_Thursday_Start_Morning) ; >>>>>>>>>> Thursday
                Global $s_Thursday_End_Morning = GUICtrlRead($id_Thursday_End_Morning)
                Global $s_Thursday_Start_Day = GUICtrlRead($id_Thursday_Start_Day)
                Global $s_Thursday_End_Day = GUICtrlRead($id_Thursday_End_Day)
                Global $s_Thursday_Start_Night = GUICtrlRead($id_Thursday_Start_Night)
                Global $s_Thursday_End_Night = GUICtrlRead($id_Thursday_End_Night)
                Global $s_Friday_Start_Morning = GUICtrlRead($id_Friday_Start_Morning) ; >>>>>>>>>> Friday
                Global $s_Friday_End_Morning = GUICtrlRead($id_Friday_End_Morning)
                Global $s_Friday_Start_Day = GUICtrlRead($id_Friday_Start_Day)
                Global $s_Friday_End_Day = GUICtrlRead($id_Friday_End_Day)
                Global $s_Friday_Start_Night = GUICtrlRead($id_Friday_Start_Night)
                Global $s_Friday_End_Night = GUICtrlRead($id_Friday_End_Night)
                Global $s_Saturday_Start_Morning = GUICtrlRead($id_Saturday_Start_Morning) ; >>>>>>>>>> Saturday
                Global $s_Saturday_End_Morning = GUICtrlRead($id_Saturday_End_Morning)
                Global $s_Saturday_Start_Day = GUICtrlRead($id_Saturday_Start_Day)
                Global $s_Saturday_End_Day = GUICtrlRead($id_Saturday_End_Day)
                Global $s_Saturday_Start_Night = GUICtrlRead($id_Saturday_Start_Night)
                Global $s_Saturday_End_Night = GUICtrlRead($id_Saturday_End_Night)
                Global $s_Sunday_Start_Morning = GUICtrlRead($id_Sunday_Start_Morning) ; >>>>>>>>>> Sunday
                Global $s_Sunday_End_Morning = GUICtrlRead($id_Sunday_End_Morning)
                Global $s_Sunday_Start_Day = GUICtrlRead($id_Sunday_Start_Day)
                Global $s_Sunday_End_Day = GUICtrlRead($id_Sunday_End_Day)
                Global $s_Sunday_Start_Night = GUICtrlRead($id_Sunday_Start_Night)
                Global $s_Sunday_End_Night = GUICtrlRead($id_Sunday_End_Night)

                Local $b_Monday_Morning = 0, $b_Monday_Day = 0
                Local $b_Tuesday_Morning = 0, $b_Tuesday_Day = 0
                Local $b_Wednesday_Morning = 0, $b_Wednesday_Day = 0
                Local $b_Thursday_Morning = 0, $b_Thursday_Day = 0
                Local $b_Friday_Morning = 0, $b_Friday_Day = 0
                Local $b_Saturday_Morning = 0, $b_Saturday_Day = 0
                Local $b_Sunday_Morning = 0, $b_Sunday_Day = 0
                Select ; ==> Start "Monday"
                    Case StringIsDigit($s_Monday_Start_Morning) = 0 And StringIsDigit($s_Monday_End_Morning) = 0
                        If PixelGetColor(2, 2, $g_Monday_Morning) = 16777215 Then
                            GUICtrlSetBkColor($g_Monday_Morning, $GUI_BKCOLOR_TRANSPARENT)
                        EndIf
                        $b_Monday_Morning = 1
                    Case StringIsDigit($s_Monday_Start_Morning) = 1 And StringIsDigit($s_Monday_End_Morning) = 1 And (Number($s_Monday_Start_Morning) < Number($s_Monday_End_Morning))
                        If PixelGetColor(2, 2, $g_Monday_Morning) = 16777215 Then
                            GUICtrlSetBkColor($g_Monday_Morning, $GUI_BKCOLOR_TRANSPARENT)
                        EndIf
                    Case Else
                        GUICtrlSetBkColor($g_Monday_Morning, 0xFF4444)
                        $b_ComboError = 1
                EndSelect
                Select
                    Case StringIsDigit($s_Monday_Start_Day) = 0 And StringIsDigit($s_Monday_End_Day) = 0
                        GUICtrlSetBkColor($g_Monday_Day, $GUI_BKCOLOR_TRANSPARENT)
                        $b_Monday_Day = 1
                    Case (StringIsDigit($s_Monday_Start_Day) = 1 And StringIsDigit($s_Monday_End_Day) = 1 And (Number($s_Monday_Start_Day) >= Number($s_Monday_End_Morning)) And (Number($s_Monday_End_Day) > Number($s_Monday_Start_Day))) Or $b_Monday_Morning = 1
                        GUICtrlSetBkColor($g_Monday_Day, $GUI_BKCOLOR_TRANSPARENT)
                    Case Else
                        GUICtrlSetBkColor($g_Monday_Day, 0xFF4444)
                        $b_ComboError = 1
                EndSelect
                Select
                    Case StringIsDigit($s_Monday_Start_Night) = 0 And StringIsDigit($s_Monday_End_Night) = 0
                        GUICtrlSetBkColor($g_Monday_Night, $GUI_BKCOLOR_TRANSPARENT)
                    Case (StringIsDigit($s_Monday_Start_Night) = 1 And StringIsDigit($s_Monday_End_Night) = 1 And (Number($s_Monday_Start_Night) >= Number($s_Monday_End_Day))) Or $b_Monday_Day = 1
                        GUICtrlSetBkColor($g_Monday_Night, $GUI_BKCOLOR_TRANSPARENT)
                    Case Else
                        GUICtrlSetBkColor($g_Monday_Night, 0xFF4444)
                        $b_ComboError = 1
                EndSelect
                Select ; ==> Start "Tuesday"
                    Case StringIsDigit($s_Tuesday_Start_Morning) = 0 And StringIsDigit($s_Tuesday_End_Morning) = 0
                        GUICtrlSetBkColor($g_Tuesday_Morning, $GUI_BKCOLOR_TRANSPARENT)
                        $b_Tuesday_Morning = 1
                    Case StringIsDigit($s_Tuesday_Start_Morning) = 1 And StringIsDigit($s_Tuesday_End_Morning) = 1 And (Number($s_Tuesday_Start_Morning) < Number($s_Tuesday_End_Morning))
                        GUICtrlSetBkColor($g_Tuesday_Morning, $GUI_BKCOLOR_TRANSPARENT)
                    Case Else
                        GUICtrlSetBkColor($g_Tuesday_Morning, 0xFF4444)
                        $b_ComboError = 1
                EndSelect
                Select
                    Case StringIsDigit($s_Tuesday_Start_Day) = 0 And StringIsDigit($s_Tuesday_End_Day) = 0
                        GUICtrlSetBkColor($g_Tuesday_Day, $GUI_BKCOLOR_TRANSPARENT)
                        $b_Tuesday_Day = 1
                    Case (StringIsDigit($s_Tuesday_Start_Day) = 1 And StringIsDigit($s_Tuesday_End_Day) = 1 And (Number($s_Tuesday_Start_Day) >= Number($s_Tuesday_End_Morning)) And (Number($s_Tuesday_End_Day) > Number($s_Tuesday_Start_Day))) Or $b_Tuesday_Morning = 1
                        GUICtrlSetBkColor($g_Tuesday_Day, $GUI_BKCOLOR_TRANSPARENT)
                    Case Else
                        GUICtrlSetBkColor($g_Tuesday_Day, 0xFF4444)
                        $b_ComboError = 1
                EndSelect
                Select
                    Case StringIsDigit($s_Tuesday_Start_Night) = 0 And StringIsDigit($s_Tuesday_End_Night) = 0
                        GUICtrlSetBkColor($g_Tuesday_Night, $GUI_BKCOLOR_TRANSPARENT)
                    Case (StringIsDigit($s_Tuesday_Start_Night) = 1 And StringIsDigit($s_Tuesday_End_Night) = 1 And (Number($s_Tuesday_Start_Night) >= Number($s_Tuesday_End_Day))) Or $b_Tuesday_Day = 1
                        GUICtrlSetBkColor($g_Tuesday_Night, $GUI_BKCOLOR_TRANSPARENT)
                    Case Else
                        GUICtrlSetBkColor($g_Tuesday_Night, 0xFF4444)
                        $b_ComboError = 1
                EndSelect
                Select ; ==> Start "Wednesday"
                    Case StringIsDigit($s_Wednesday_Start_Morning) = 0 And StringIsDigit($s_Wednesday_End_Morning) = 0
                        GUICtrlSetBkColor($g_Wednesday_Morning, $GUI_BKCOLOR_TRANSPARENT)
                        $b_Wednesday_Morning = 1
                    Case StringIsDigit($s_Wednesday_Start_Morning) = 1 And StringIsDigit($s_Wednesday_End_Morning) = 1 And (Number($s_Wednesday_Start_Morning) < Number($s_Wednesday_End_Morning))
                        GUICtrlSetBkColor($g_Wednesday_Morning, $GUI_BKCOLOR_TRANSPARENT)
                    Case Else
                        GUICtrlSetBkColor($g_Wednesday_Morning, 0xFF4444)
                        $b_ComboError = 1
                EndSelect
                Select
                    Case StringIsDigit($s_Wednesday_Start_Day) = 0 And StringIsDigit($s_Wednesday_End_Day) = 0
                        GUICtrlSetBkColor($g_Wednesday_Day, $GUI_BKCOLOR_TRANSPARENT)
                        $b_Wednesday_Day = 1
                    Case (StringIsDigit($s_Wednesday_Start_Day) = 1 And StringIsDigit($s_Wednesday_End_Day) = 1 And (Number($s_Wednesday_Start_Day) >= Number($s_Wednesday_End_Morning)) And (Number($s_Wednesday_End_Day) > Number($s_Wednesday_Start_Day))) Or $b_Wednesday_Morning = 1
                        GUICtrlSetBkColor($g_Wednesday_Day, $GUI_BKCOLOR_TRANSPARENT)
                    Case Else
                        GUICtrlSetBkColor($g_Wednesday_Day, 0xFF4444)
                        $b_ComboError = 1
                EndSelect
                Select
                    Case StringIsDigit($s_Wednesday_Start_Night) = 0 And StringIsDigit($s_Wednesday_End_Night) = 0
                        GUICtrlSetBkColor($g_Wednesday_Night, $GUI_BKCOLOR_TRANSPARENT)
                    Case (StringIsDigit($s_Wednesday_Start_Night) = 1 And StringIsDigit($s_Wednesday_End_Night) = 1 And (Number($s_Wednesday_Start_Night) >= Number($s_Wednesday_End_Day))) Or $b_Wednesday_Day = 1
                        GUICtrlSetBkColor($g_Wednesday_Night, $GUI_BKCOLOR_TRANSPARENT)
                    Case Else
                        GUICtrlSetBkColor($g_Wednesday_Night, 0xFF4444)
                        $b_ComboError = 1
                EndSelect
                Select ; ==> Start "Thursday"
                    Case StringIsDigit($s_Thursday_Start_Morning) = 0 And StringIsDigit($s_Thursday_End_Morning) = 0
                        GUICtrlSetBkColor($g_Thursday_Morning, $GUI_BKCOLOR_TRANSPARENT)
                        $b_Thursday_Morning = 1
                    Case StringIsDigit($s_Thursday_Start_Morning) = 1 And StringIsDigit($s_Thursday_End_Morning) = 1 And (Number($s_Thursday_Start_Morning) < Number($s_Thursday_End_Morning))
                        GUICtrlSetBkColor($g_Thursday_Morning, $GUI_BKCOLOR_TRANSPARENT)
                    Case Else
                        GUICtrlSetBkColor($g_Thursday_Morning, 0xFF4444)
                        $b_ComboError = 1
                EndSelect
                Select
                    Case StringIsDigit($s_Thursday_Start_Day) = 0 And StringIsDigit($s_Thursday_End_Day) = 0
                        GUICtrlSetBkColor($g_Thursday_Day, $GUI_BKCOLOR_TRANSPARENT)
                        $b_Thursday_Day = 1
                    Case (StringIsDigit($s_Thursday_Start_Day) = 1 And StringIsDigit($s_Thursday_End_Day) = 1 And (Number($s_Thursday_Start_Day) >= Number($s_Thursday_End_Morning)) And (Number($s_Thursday_End_Day) > Number($s_Thursday_Start_Day))) Or $b_Thursday_Morning = 1
                        GUICtrlSetBkColor($g_Thursday_Day, $GUI_BKCOLOR_TRANSPARENT)
                    Case Else
                        GUICtrlSetBkColor($g_Thursday_Day, 0xFF4444)
                        $b_ComboError = 1
                EndSelect
                Select
                    Case StringIsDigit($s_Thursday_Start_Night) = 0 And StringIsDigit($s_Thursday_End_Night) = 0
                        GUICtrlSetBkColor($g_Thursday_Night, $GUI_BKCOLOR_TRANSPARENT)
                    Case (StringIsDigit($s_Thursday_Start_Night) = 1 And StringIsDigit($s_Thursday_End_Night) = 1 And (Number($s_Thursday_Start_Night) >= Number($s_Thursday_End_Day))) Or $b_Thursday_Day = 1
                        GUICtrlSetBkColor($g_Thursday_Night, $GUI_BKCOLOR_TRANSPARENT)
                    Case Else
                        GUICtrlSetBkColor($g_Thursday_Night, 0xFF4444)
                        $b_ComboError = 1
                EndSelect
                Select ; ==> Start "Friday"
                    Case StringIsDigit($s_Friday_Start_Morning) = 0 And StringIsDigit($s_Friday_End_Morning) = 0
                        GUICtrlSetBkColor($g_Friday_Morning, $GUI_BKCOLOR_TRANSPARENT)
                        $b_Friday_Morning = 1
                    Case StringIsDigit($s_Friday_Start_Morning) = 1 And StringIsDigit($s_Friday_End_Morning) = 1 And (Number($s_Friday_Start_Morning) < Number($s_Friday_End_Morning))
                        GUICtrlSetBkColor($g_Friday_Morning, $GUI_BKCOLOR_TRANSPARENT)
                    Case Else
                        GUICtrlSetBkColor($g_Friday_Morning, 0xFF4444)
                        $b_ComboError = 1
                EndSelect
                Select
                    Case StringIsDigit($s_Friday_Start_Day) = 0 And StringIsDigit($s_Friday_End_Day) = 0
                        GUICtrlSetBkColor($g_Friday_Day, $GUI_BKCOLOR_TRANSPARENT)
                        $b_Friday_Day = 1
                    Case (StringIsDigit($s_Friday_Start_Day) = 1 And StringIsDigit($s_Friday_End_Day) = 1 And (Number($s_Friday_Start_Day) >= Number($s_Friday_End_Morning)) And (Number($s_Friday_End_Day) > Number($s_Friday_Start_Day))) Or $b_Friday_Morning = 1
                        GUICtrlSetBkColor($g_Friday_Day, $GUI_BKCOLOR_TRANSPARENT)
                    Case Else
                        GUICtrlSetBkColor($g_Friday_Day, 0xFF4444)
                        $b_ComboError = 1
                EndSelect
                Select
                    Case StringIsDigit($s_Friday_Start_Night) = 0 And StringIsDigit($s_Friday_End_Night) = 0
                        GUICtrlSetBkColor($g_Friday_Night, $GUI_BKCOLOR_TRANSPARENT)
                    Case (StringIsDigit($s_Friday_Start_Night) = 1 And StringIsDigit($s_Friday_End_Night) = 1 And (Number($s_Friday_Start_Night) >= Number($s_Friday_End_Day))) Or $b_Friday_Day = 1
                        GUICtrlSetBkColor($g_Friday_Night, $GUI_BKCOLOR_TRANSPARENT)
                    Case Else
                        GUICtrlSetBkColor($g_Friday_Night, 0xFF4444)
                        $b_ComboError = 1
                EndSelect
                Select ; ==> Start "Saturday"
                    Case StringIsDigit($s_Saturday_Start_Morning) = 0 And StringIsDigit($s_Saturday_End_Morning) = 0
                        GUICtrlSetBkColor($g_Saturday_Morning, $GUI_BKCOLOR_TRANSPARENT)
                        $b_Saturday_Morning = 1
                    Case StringIsDigit($s_Saturday_Start_Morning) = 1 And StringIsDigit($s_Saturday_End_Morning) = 1 And (Number($s_Saturday_Start_Morning) < Number($s_Saturday_End_Morning))
                        GUICtrlSetBkColor($g_Saturday_Morning, $GUI_BKCOLOR_TRANSPARENT)
                    Case Else
                        GUICtrlSetBkColor($g_Saturday_Morning, 0xFF4444)
                        $b_ComboError = 1
                EndSelect
                Select
                    Case StringIsDigit($s_Saturday_Start_Day) = 0 And StringIsDigit($s_Saturday_End_Day) = 0
                        GUICtrlSetBkColor($g_Saturday_Day, $GUI_BKCOLOR_TRANSPARENT)
                        $b_Saturday_Day = 1
                    Case (StringIsDigit($s_Saturday_Start_Day) = 1 And StringIsDigit($s_Saturday_End_Day) = 1 And (Number($s_Saturday_Start_Day) >= Number($s_Saturday_End_Morning)) And (Number($s_Saturday_End_Day) > Number($s_Saturday_Start_Day))) Or $b_Saturday_Morning = 1
                        GUICtrlSetBkColor($g_Saturday_Day, $GUI_BKCOLOR_TRANSPARENT)
                    Case Else
                        GUICtrlSetBkColor($g_Saturday_Day, 0xFF4444)
                        $b_ComboError = 1
                EndSelect
                Select
                    Case StringIsDigit($s_Saturday_Start_Night) = 0 And StringIsDigit($s_Saturday_End_Night) = 0
                        GUICtrlSetBkColor($g_Saturday_Night, $GUI_BKCOLOR_TRANSPARENT)
                    Case (StringIsDigit($s_Saturday_Start_Night) = 1 And StringIsDigit($s_Saturday_End_Night) = 1 And (Number($s_Saturday_Start_Night) >= Number($s_Saturday_End_Day))) Or $b_Saturday_Day = 1
                        GUICtrlSetBkColor($g_Saturday_Night, $GUI_BKCOLOR_TRANSPARENT)
                    Case Else
                        GUICtrlSetBkColor($g_Saturday_Night, 0xFF4444)
                        $b_ComboError = 1
                EndSelect
                Select ; ==> Start "Sunday"
                    Case StringIsDigit($s_Sunday_Start_Morning) = 0 And StringIsDigit($s_Sunday_End_Morning) = 0
                        GUICtrlSetBkColor($g_Sunday_Morning, $GUI_BKCOLOR_TRANSPARENT)
                        $b_Sunday_Morning = 1
                    Case StringIsDigit($s_Sunday_Start_Morning) = 1 And StringIsDigit($s_Sunday_End_Morning) = 1 And (Number($s_Sunday_Start_Morning) < Number($s_Sunday_End_Morning))
                        GUICtrlSetBkColor($g_Sunday_Morning, $GUI_BKCOLOR_TRANSPARENT)
                    Case Else
                        GUICtrlSetBkColor($g_Sunday_Morning, 0xFF4444)
                        $b_ComboError = 1
                EndSelect
                Select
                    Case StringIsDigit($s_Sunday_Start_Day) = 0 And StringIsDigit($s_Sunday_End_Day) = 0
                        GUICtrlSetBkColor($g_Sunday_Day, $GUI_BKCOLOR_TRANSPARENT)
                        $b_Sunday_Day = 1
                    Case (StringIsDigit($s_Sunday_Start_Day) = 1 And StringIsDigit($s_Sunday_End_Day) = 1 And (Number($s_Sunday_Start_Day) >= Number($s_Sunday_End_Morning)) And (Number($s_Sunday_End_Day) > Number($s_Sunday_Start_Day))) Or $b_Sunday_Morning = 1
                        GUICtrlSetBkColor($g_Sunday_Day, $GUI_BKCOLOR_TRANSPARENT)
                    Case Else
                        GUICtrlSetBkColor($g_Sunday_Day, 0xFF4444)
                        $b_ComboError = 1
                EndSelect
                Select
                    Case StringIsDigit($s_Sunday_Start_Night) = 0 And StringIsDigit($s_Sunday_End_Night) = 0
                        GUICtrlSetBkColor($g_Sunday_Night, $GUI_BKCOLOR_TRANSPARENT)
                    Case (StringIsDigit($s_Sunday_Start_Night) = 1 And StringIsDigit($s_Sunday_End_Night) = 1 And (Number($s_Sunday_Start_Night) >= Number($s_Sunday_End_Day))) Or $b_Sunday_Day = 1
                        GUICtrlSetBkColor($g_Sunday_Night, $GUI_BKCOLOR_TRANSPARENT)
                    Case Else
                        GUICtrlSetBkColor($g_Sunday_Night, 0xFF4444)
                        $b_ComboError = 1
                EndSelect

                If $b_ComboError = 0 Then
                    MsgBox(64, "", "ok !")
                EndIf
        EndSwitch
    WEnd

    GUIDelete($h_GUI)
EndFunc

 

Qui ose gagneWho Dares Win[left]CyberExploit[/left]

Link to comment
Share on other sites

So basically you want us to debug your code, right ?  Well good luck with that.  If you want help, make a runable snippet of the code you have trouble with, and then we will help you.

Link to comment
Share on other sites

While agreeing with nine and logan i noticed that you create the gui inside the function, and at the very end of the function you use GUIDelete, I'd guess that would cause some flickering.

Why is the GUIDelete there?

Some guy's script + some other guy's script = my script!

Link to comment
Share on other sites

GUIDelete() is if we close the window the with Case $GUI_EVENT_CLOSE => ExitLoop

Why it's not a good idea to create a gui inside a function ?

 

@Nine for the moment I have only created the graphical interface. And before to run another function, I would like to remove flickering.

 

Qui ose gagneWho Dares Win[left]CyberExploit[/left]

Link to comment
Share on other sites

I have test it but no flashes (flickering) effect detect .  Autoit (3.3.16.1)  Windows (10 Pro Version 22H2)

Tip:

  1. Declare all Global Variable outside from function, and inside just assign. (if the program is only this, the Global Variable not needed)
  2. Declare all Locale Variable outside from While loop , and inside just assign

I know that I know nothing

Link to comment
Share on other sites

  • Solution

I was playing with this just for fun.
I know you made this the way you know and the way you can, but let me say that soon or later you can't maintain this code, there are too much variables, too much to keep in mind.

The problem/bugs are on such lines of code:
 

Case (StringIsDigit($s_Tuesday_Start_Day) = 1 And
 StringIsDigit($s_Tuesday_End_Day) = 1 And
 (Number($s_Tuesday_Start_Day) >= Number($s_Tuesday_End_Morning)) And
 (Number($s_Tuesday_End_Day) > Number($s_Tuesday_Start_Day)))
 Or $b_Tuesday_Morning = 1


Let's talk about all the "And": it means that whenever a single condition is false, everything is false, no matter parenthesis are placed.

The real problem is that all comboboxes have the same range of hours, it is an inconsistent interface, I mean there is no sense that you can setup:
Morning start: 00
Morning end: 22

This range of hours are overlapping Day and Night periods. I really don't know what's mean for you "morning start hour", "morning end hour" and so on.
If you could split range hours into a non overlapping ranges, you need to do none error check because you don't allow user to create those errors.
It would be easy for you as a developer and as a "program user".

This is the way I made it:

#include <File.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <Date.au3>
#include <ComboConstants.au3>

Global $aDays[7][7]  ; holds all control ID created by GUI
Global $aData[7][7]  ; holds all data chosen by user on comboboxes and Checkboxes
Global $aRed[7][3]   ; holds aRedZones that includes 2 comboboxes. So there are only 3 on any row

; columns constants
Global $CheckBox=0, $MorningStart = 1, $MorningEnd = 2, $DayStart=3 , $DayEnd=4, $NightStart=5, $NightEnd =6
; row constants
Global Const $Mon=0 , $Tue=1, $Wed=2 , $Thi=3, $Fri=4, $Sat=5, $Sun=6  ; row constants
Local Const $a_Days[7] = ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"]
Local $a_Hours[25] = [" -", "00", "01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23"]
;Red Zone Columns:
Local Const $Morning = 0 , $Day=1 , $Night = 2


Local Const $cbow = 40  ; comboboxes width to calculate positions
Local $h_GUI = GUICreate("Automat Counting", 672, 400, -1, -1)
Local Const $a_Times[3] = ["Morning", "Day", "Night"]
Local $a_WindowClientArea_Size = WinGetClientSize($h_GUI) ;$a_WindowClientArea_Size[0] = Width, $a_WindowClientArea_Size[1] = Height
GUISetFont(10)
GUICtrlCreateGroup("Days", 10, 10, $a_WindowClientArea_Size[0] - 20, 360)
GUICtrlCreateGroup("", 110, 35, 175, 315)
GUICtrlCreateLabel("Morning", 110, 25, 175, 24, BitOR($SS_CENTERIMAGE, $SS_CENTER))
GUICtrlSetColor(-1, 0x003e51)
GUICtrlSetBkColor(-1, 0x00c4ba)
GUICtrlCreateGroup("", 290, 35, 155, 315)
GUICtrlCreateLabel("Day", 290, 25, 155, 24, BitOR($SS_CENTERIMAGE, $SS_CENTER))
GUICtrlSetColor(-1, 0x003e51)
GUICtrlSetBkColor(-1, 0x00c4ba)
GUICtrlCreateGroup("", 450, 35, 155, 315)
GUICtrlCreateLabel("Night", 450, 25, 155, 24, BitOR($SS_CENTERIMAGE, $SS_CENTER))
GUICtrlSetColor(-1, 0x003e51)
GUICtrlSetBkColor(-1, 0x00c4ba)
$id_Launch = GUICtrlCreateButton("Start", $a_WindowClientArea_Size[0] / 2 - 100, $a_WindowClientArea_Size[1] - 35, 200, 25)

GUICtrlCreateLabel("Start",  160, 55 , 39, 24, $SS_CENTERIMAGE)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)

GUICtrlCreateLabel("End",240, 55, 39,24, $SS_CENTERIMAGE)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
GUICtrlCreateLabel("Start",  320, 55 , 39, 24, $SS_CENTERIMAGE)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
GUICtrlCreateLabel("End",  400, 55 , 39, 24, $SS_CENTERIMAGE)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
GUICtrlCreateLabel("Start",  480, 55 , 39, 24, $SS_CENTERIMAGE)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
GUICtrlCreateLabel("End",  560, 55 , 39, 24, $SS_CENTERIMAGE)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)

For $irow=0 To 6
     ;Top Coordenate: 80 + 40*$irow  = start at 80 minimum, then move down 40 pixels per each row
    $aDays[$irow][$CheckBox] = GUICtrlCreateCheckbox($a_Days[$irow] , 20, 80 + 40*$irow, 80, 24)

    GUICtrlSetState(-1, $GUI_CHECKED)
    $aRed[$irow][0] = GUICtrlCreateGraphic( 79+($cbow* 2 ) - 10,  76 + 40*$irow, $cbow*3 +15 , 32)
    GuiCtrlSetBkColor($aRed[$irow][0],  0xFF4444)
    GUICtrlSetState(-1, $GUI_DISABLE)
    $aRed[$irow][1] = GUICtrlCreateGraphic( 79+($cbow* 6) - 10,  76 + 40*$irow, $cbow*3 +15 , 32)
    GuiCtrlSetBkColor($aRed[$irow][1],  0xFF4444)
    GUICtrlSetState(-1, $GUI_DISABLE)
    $aRed[$irow][2] = GUICtrlCreateGraphic( 79+($cbow* 10) - 10,  76 + 40*$irow, $cbow*3 +15 , 32)
    GuiCtrlSetBkColor($aRed[$irow][2],  0xFF4444)
    GUICtrlSetState(-1, $GUI_DISABLE)

    For $icol=1 To 6
        ;Left Coordenate: 80+($cbow*2* $icol)  = start left at 80 minimum. Then multiply by 2 the width of the combo to move to the right per each column
        ;Top Coordenate: 40*$irow + 80  = start at 80 minimum. Move down 40 pixel per each row
        $aDays[$irow][$icol]= GUICtrlCreateCombo("", 80+($cbow* 2 * $icol), 80 + 40*$irow, $cbow, 24, $CBS_DROPDOWNLIST)
        GUICtrlSetData($aDays[$irow][$icol], _ArrayToString($a_Hours), " -")

    Next
Next

GUISetState(@SW_SHOW, $h_GUI)
Sleep(1000)
; hide Red Zones instead of checking its color pixels.
; with some screen animation... because I can!
For $irow=6 To 0 Step -1
    GUICtrlSetState($aRed[$irow][$Night], $GUI_HIDE)
    Sleep(100)
    GUICtrlSetState($aRed[$irow][$Day], $GUI_HIDE)
    Sleep(100)
    GUICtrlSetState($aRed[$irow][$Morning], $GUI_HIDE)
    Sleep(100)
Next
; Show one of them randomly, sleep and hide it,
; just to demonstrate how to show and hide.
Sleep(1000)
GUICtrlSetState($aRed[$Wed][$Day], $GUI_SHOW)
Sleep(1000)
GUICtrlSetState($aRed[$Wed][$Day], $GUI_HIDE)

; GUISetState(@SW_SHOW, $h_GUI) ; if you activate this line an comment out line 76, you will not see any animation on screen. You should also remove any Sleep call.

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            ExitLoop
         Case $id_Launch
            Local $b_ComboError = 0
            Update_Data()
            Check_Data()
            ;_ArrayDisplay($aData, "Data Retrieved from Interface", "", 0,"|", "Day|Morning Start|Morning End|Day Start|Day End|Night Start|Night End")
    EndSwitch
WEnd


Func Check_Data()
    local $ms =0, $me=0, $ds=0 , $de=0, $ns=0, $ne=0  ; all data from one row

    For $irow =0 To 6
        ; check full row values
        $ms = GetaData($irow, $MorningStart)
        $me = GetaData($irow, $MorningEnd)
        $ds = GetaData($irow, $DayStart)
        $de = GetaData($irow, $DayEnd)
        $ns = GetaData($irow, $NightStart)
        $ne = GetaData($irow, $NightEnd)

        ConsoleWrite(StringPad(GetaData( $irow), 15) & " ms " & Pad($ms) & " me " & Pad($me)& " ds " & Pad($ds)& " de " & Pad($de) & " ns " & Pad($ns) & " ne "& Pad($ne)  & @CRLF)
        If ($ms = -1 and $me = -1) or  ($ms < $me)  Then
                ; If combos are not setup by user, RedZone should be hidden.
            GUICtrlSetState($aRed[$irow][$Morning], $GUI_HIDE)
        Else
            GUICtrlSetState($aRed[$irow][$Morning], $GUI_SHOW)
        EndIf

        If (($ds = -1 and $de = -1) or  ($ds < $de)) Then  ; BUG: This is wrong, doesn't work properly I don't understand how it is supposed to work though
                ; If combos are not setup by user, RedZone should be hidden.
            GUICtrlSetState($aRed[$irow][$Day], $GUI_HIDE)
        Else
            If ( $ms=-1 and $me=-1) Then
                GUICtrlSetState($aRed[$irow][$Day], $GUI_HIDE)
            ElseIf  ($me > $ds) Then
                GUICtrlSetState($aRed[$irow][$Day], $GUI_SHOW)
            EndIf
        EndIf

        If ($ns= -1 and $ne = -1)  or ($ns < $ne ) Then
                ; If combos are not setup by user, RedZone should be hidden.
            GUICtrlSetState($aRed[$irow][$Night], $GUI_HIDE) ;
        Else
            GUICtrlSetState($aRed[$irow][$Day], $GUI_SHOW)
        EndIf

    Next
    ConsoleWrite("------------------------------------------------------------" & @CRLF)

EndFunc


; Get Data of any control on screen,
; Examples:
;   GetData( $Mon, $DayEnd) -  Get data from Monday at DayEnd
;   GetData( $Tue )         -  Get the name of the day  "Tuesday"
Func GetData($row, $col=0)
    If $col = 0 Then
        ; we already have those names in our array
        Return $a_Days[$row]
    Else
        return GUICtrlRead($aDays[$row][$col])
    EndIf
EndFunc


; another way to get the data.
; instead of asking interface everytime, we use an Array
; just like $aDays, but we save here all screen data user.
Func Update_Data()
    local $txt = ""
    For $i=0 To 6
        For $j=0 To 6
            If $j=0 Then
                $aData[$i][$j]= GUICtrlRead($aDays[$i][$j], $GUI_READ_EXTENDED)     ; saves the day of the week on column Zero
                ;$aData[$i][$j]= GUICtrlRead($aDays[$i][$j]) = 1                            ; saves  True (checked) or False  (unchecked) on column Zero
            Else
                $txt = GUICtrlRead($aDays[$i][$j])
                If stringIsDigit($txt) Then
                    $aData[$i][$j] = int($txt)  ; convert all data to integers numbers
                Else
                    $aData[$i][$j] = -1 ; Zero is used by MidNight hour, so I setup -1 on empty selection.
                EndIf
            EndIf
        Next
    Next
EndFunc

; if you do not like all those square bracket on your code
; you could minimize their use by calling this function.
; Examples:
;   GetaData( $Mon, $DayEnd)        -  Get data from Monday at DayEnd
;   GetaData( $Mon, $DayEnd -1 )    - Since DayEnd is an integer, here we get $DayStart
;   GetaData( $Tue )                -  Get the name of the day  "Tuesday" if you saved on Zero column the day of the week
Func GetaData($row, $col=0)
    return $aData[$row][$col]
EndFunc


; a way to get a Value from the $aData only if
; is an Integer value >= 0
; local $data
; If IsValidHour( $Tue, $MorningEnd , $data)Then
;     ; here $data is always a number defined by user: from Zero to 23
; Else
;     ; here $data could be a string value (day of the week)
;     ; or maybe -1
;     ; of maybe True/False depending on what you saved on Zero Column.
; EndIf

Func IsValidaHour($row, $col, byRef $Value)
    ; we guarantee that we are returning and integer value
    ; greater than -1, that is, the user specified a valid
    ; hour.
    ; if col is Zero it returns false because it is the
    ; day of the week, it is a string what you get on $Value

    $value = $aData[$row][$col]
    return ($col > 0) and ($Value > -1)
EndFunc

Func Pad($tNumber, $padding = 2)
    If $padding > 10 Then
        Return "-1"
    EndIf
    Return StringRight('0000000000' & $tNumber, $padding)
EndFunc   ;==>Pad

Func StringPad($sAString,  $imaxLength)
    Local $i =  StringLen($sAString)
    If $i <= $imaxLength Then
        Return  StringFormat("%-" &  $imaxLength & "s" ,  $sAString)
    EndIf
    Return $sAString
EndFunc

 

Link to comment
Share on other sites

@Lepes Thanks a lot for your job.

In fact, at the beginning there was no graphical interface. As soon as users have a choice, we must check all controls !

In my company they asked me to develop a program which count tests.

An example of file:

06/04/23,05:00,0015
06/04/23,05:05,0009
06/04/23,05:10,0006
06/04/23,05:15,0000
06/04/23,05:20,0002
06/04/23,05:25,0015
06/04/23,05:30,0000
06/04/23,05:35,0014
06/04/23,05:40,0015
06/04/23,05:45,0000
06/04/23,05:50,0015

In the 3rd colum I have a number I must count for the range (the user put in the graphical interface). As you can see the 2nd colum is is the time in 5 minute increments.

 

Edited by jerem488

Qui ose gagneWho Dares Win[left]CyberExploit[/left]

Link to comment
Share on other sites

@Nine

Now I've made good progress and even finished the code. Maybe not in the best way... But when I posted the problem I had nothing else done

It was not in my interest not to publish the code 

Qui ose gagneWho Dares Win[left]CyberExploit[/left]

Link to comment
Share on other sites

  • 3 weeks later...

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...