Jump to content
nitekram

ComboBox updating items

Recommended Posts

nitekram

I have been trying to get this to work in my script...after creating an example script to ask a question, my original reason for writing the example was resolved. But I then found another issue that I am having trouble figuring out.

What I want is a combo list that is dynamic. I want the list to remove items that have been selected, and add items that have been changed. I have am still trying to resolve, but thought I would post it and see if I can get an answer.

; example of removing combo items, and updating the combo list for all remaining combos - including those that already have been asigned
#include <GUIConstantsEx.au3>
#include <array.au3>

Global $aComboList[16], $ahCombo[16], $iCount = 0
; create the value of the combo list - using array to create values
For $x = 1 To UBound($aComboList) - 1
    $aComboList[$x] = $x
Next
;_ArrayDisplay($aComboList)
Global $aTempArray = $aComboList
; convert the array into a string that can be used on a combo control
Global $sComboString = _ArrayToString($aComboList)

; create the gui
Global $hGUI = GUICreate('Combo Remove Test', 250, 475)
; create the combos
For $x = 1 To UBound($ahCombo) - 1
    If $x = 1 Then
        $ahCombo[$x] = GUICtrlCreateCombo('', 10, 10)
        GUICtrlSetData(-1, $sComboString)
    Else
        $ahCombo[$x] = GUICtrlCreateCombo('', 10, 10 + $iCount)
        GUICtrlSetData(-1, $sComboString)
    EndIf
    $iCount += 30
Next

; Display the GUI.
GUISetState(@SW_SHOW, $hGUI)
; main loop
While 1
    $msg = GUIGetMsg()
    If $msg = $GUI_EVENT_CLOSE Then ExitLoop
    ; check if values have been updated in on the combo controls
    For $x = 1 To UBound($ahCombo) - 1
        If $ahCombo[$x] = $msg Then
            RemoveIndex($ahCombo[$x]) ; delete the value from the string, so it cannot be used in other combos
        EndIf
    Next

WEnd

; Delete the previous GUI and all controls.
GUIDelete($hGUI)

Func RemoveIndex($hItem)
    ;_GUICtrlComboBox_GetList (not being used)
    Local $sTempComboValue = ''
    Local $sComboListTemp

    ConsoleWrite('Removing Item from Array - ' & GUICtrlRead($hItem) & @CRLF)
    For $x = UBound($aTempArray) - 1 To 0 Step -1
        If GUICtrlRead($hItem) = $aTempArray[$x] Then
            _ArrayDelete($aTempArray, $x)
            ;
            ExitLoop
        EndIf
    Next
    ;_ArrayDisplay($aTempArray)
    ; update all combos to the new string
    $sComboListTemp = _ArrayToString($aTempArray)
    For $x = 0 To UBound($ahCombo) - 1

        If GUICtrlRead($ahCombo[$x]) = '' Then
            ; if nothing has been selected, update with new combo list for future selection
            GUICtrlSetData($ahCombo[$x], '')
            GUICtrlSetData($ahCombo[$x], $sComboListTemp)

        ElseIf GUICtrlRead($ahCombo[$x]) <> '' Then
            ; if value already exist then keep value
            $sTempComboValue = GUICtrlRead($ahCombo[$x])
            ; set new combo list for this item

            For $y = UBound($aTempArray) - 1 To 0 Step -1
                If $aTempArray[$y] = '' Then
                    _ArrayDelete($aTempArray, $y)
                    $sComboListTemp = _ArrayToString($aTempArray)
                EndIf
            Next




; need a way to add the value back, if there was an item removed from selection for the calling control, and it is not being used elsewhere
#cs

            ;If Not StringInStr($sComboListTemp, $sTempComboValue) Then $sComboListTemp &= '|' & $sTempComboValue

            ; check for selected value being used, if it is not being used, then reinsert
            Local $sNewComboList = ''
            For $z = 1 To UBound($ahCombo) - 1
                If $z = UBound($ahCombo) - 1 Then ExitLoop
                $sNewComboList &= GUICtrlRead($ahCombo[$z]) & '|'
            Next
            Local $aNewComboList = StringSplit($sNewComboList, '|', 2)
            ;_ArrayDisplay($aNewComboList)

            ; Compare the strings
            $sNewComboList &= $sComboListTemp & $sComboString

            $aTempArray = _ArrayUnique($aNewComboList)
            _ArrayDisplay($aTempArray)
            _ArrayAdd($aTempArray, '')
            $sNewComboList = _ArrayToString($aTempArray)
#ce


            GUICtrlSetData($ahCombo[$x], '')
            GUICtrlSetData($ahCombo[$x], $sTempComboValue & '|' & $sComboListTemp, $sTempComboValue)
            ;GUICtrlSetData($ahCombo[$x], $sTempComboValue & '|' & $sNewComboList, $sTempComboValue)
            ;GUICtrlSetData($ahCombo[$x], $sNewComboList, $sTempComboValue)
        EndIf

    Next
EndFunc   ;==>RemoveIndex

 


All by me:

"Sometimes you have to go back to where you started, to get to where you want to go." 

"Everybody catches up with everyone, eventually" 

"As you teach others, you are really teaching yourself."

From my dad

"Do not worry about yesterday, as the only thing that you can control is tomorrow."

 

WindowsError.gif

WIKI | Tabs; | Arrays; | Strings | Wiki Arrays | How to ask a Question | Forum Search | FAQ | Tutorials | Original FAQ | ONLINE HELP | UDF's Wiki | AutoIt PDF

AutoIt Snippets | Multple Guis | Interrupting a running function | Another Send

StringRegExp | StringRegExp Help | RegEXTester | REG TUTOR | Reg TUTOT 2

AutoItSetOption | Macros | AutoIt Snippets | Wrapper | Autoit  Docs

SCITE | SciteJump | BB | MyTopics | Programming | UDFs | AutoIt 123 | UDFs Form | UDF

Learning to script | Tutorials | Documentation | IE.AU3 | Games? | FreeSoftware | Path_Online | Core Language

Programming Tips

Excel Changes

ControlHover.UDF

GDI_Plus

Draw_On_Screen

GDI Basics

GDI_More_Basics

GDI Rotate

GDI Graph

GDI  CheckExistingItems

GDI Trajectory

Replace $ghGDIPDll with $__g_hGDIPDll

DLL 101?

Array via Object

GDI Swimlane

GDI Plus French 101 Site

GDI Examples UEZ

GDI Basic Clock

GDI Detection

Ternary operator

Share this post


Link to post
Share on other sites
Melba23

nitekram,

That was a fun little problem. This seems to work for me - does it meet your requirements?

#include <GUIConstantsEx.au3>
#include <Array.au3>

Global $aComboList[16], $ahCombo[16], $iCount = 0

For $x = 1 To UBound($aComboList) - 1
    $aComboList[$x] = $x
Next
Global $sComboString = _ArrayToString($aComboList)
ConsoleWrite($sComboString & @CRLF)

; create the gui
Global $hGUI = GUICreate('Combo Remove Test', 250, 475)
; create the combos
For $x = 1 To UBound($ahCombo) - 1
    $ahCombo[$x] = GUICtrlCreateCombo('', 10, (30 * $x) - 20)
    GUICtrlSetData(-1, $sComboString)
Next

; Display the GUI.
GUISetState(@SW_SHOW, $hGUI)

; main loop
While 1
    $msg = GUIGetMsg()
    If $msg = $GUI_EVENT_CLOSE Then ExitLoop
    ; check if values have been updated in on the combo controls
    For $x = 1 To UBound($ahCombo) - 1
        If $ahCombo[$x] = $msg Then
            _AlterCombos() ; delete the value from the string, so it cannot be used in other combos
        EndIf
    Next
WEnd

; Delete the previous GUI and all controls.
GUIDelete($hGUI)

Func _AlterCombos()

    ; Capy the original full data string - add final "|" for matching
    $sNewString = $sComboString & "|"

    ; Now remove all currently selected items
    For $i = 1 To UBound($ahCombo) - 1
        If GUICtrlRead($ahCombo[$i]) Then
            $sNewString = StringReplace($sNewString, "|" & GUICtrlRead($ahCombo[$i]) & "|", "|")
        EndIf
    Next
    ; Remove final "|"
    $sNewString = StringTrimRight($sNewString, 1)

    ; Change the data for each combo - restoring the currently selected item for those that have one
    For $i = 1 To UBound($ahCombo) - 1
        $sCurrSel = GUICtrlRead($ahCombo[$i])
        $sThisString = $sNewString & "|" & $sCurrSel
        GUICtrlSetData($ahCombo[$i], $sThisString, $sCurrSel)
    Next

EndFunc   ;==>_AlterCombos

M23

Edited by Melba23
Amended code to cater for edge case

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites
nitekram

That worked as planned...guess I was trying to complicate it. Sometimes I would just like to watch the thought processes of the coders here, that know what they are doing.

 

Thanks again.


All by me:

"Sometimes you have to go back to where you started, to get to where you want to go." 

"Everybody catches up with everyone, eventually" 

"As you teach others, you are really teaching yourself."

From my dad

"Do not worry about yesterday, as the only thing that you can control is tomorrow."

 

WindowsError.gif

WIKI | Tabs; | Arrays; | Strings | Wiki Arrays | How to ask a Question | Forum Search | FAQ | Tutorials | Original FAQ | ONLINE HELP | UDF's Wiki | AutoIt PDF

AutoIt Snippets | Multple Guis | Interrupting a running function | Another Send

StringRegExp | StringRegExp Help | RegEXTester | REG TUTOR | Reg TUTOT 2

AutoItSetOption | Macros | AutoIt Snippets | Wrapper | Autoit  Docs

SCITE | SciteJump | BB | MyTopics | Programming | UDFs | AutoIt 123 | UDFs Form | UDF

Learning to script | Tutorials | Documentation | IE.AU3 | Games? | FreeSoftware | Path_Online | Core Language

Programming Tips

Excel Changes

ControlHover.UDF

GDI_Plus

Draw_On_Screen

GDI Basics

GDI_More_Basics

GDI Rotate

GDI Graph

GDI  CheckExistingItems

GDI Trajectory

Replace $ghGDIPDll with $__g_hGDIPDll

DLL 101?

Array via Object

GDI Swimlane

GDI Plus French 101 Site

GDI Examples UEZ

GDI Basic Clock

GDI Detection

Ternary operator

Share this post


Link to post
Share on other sites
nitekram

Okay, on the surface, it works, but not for my script. I tried to make an easy example, but it was two easy. I have more combo boxes, with different arrays, pulling from the same string. I might be able to figure this out, when I am less tired, but when working on this for a few hours before posting.

Here is my code...though I just started it - if anyone finds a way to make it smaller, please share.

 

Still trying to do the same thing...make is so once the item is picked, remove from string, and if it is available, add it back to the string.

; choir keeper
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <array.au3>

Global $cDaysOff = '0x00ff00'
Global $aTime[23]
Global $aSunday[5][6], $aMonday[5][6], $aTuesday[5][6], $aWednesday[5][6], $aThursday[5][6], $aFriday[5][6], $aSaturday[5][6]
Global $sComboChores = ''
Global $aChores[23][3] = [ _
        ['Kitchen', False, $aTime[1]], _
        ['Master Bed Room', False, $aTime[2]], _
        ['Front Bed Room', False, $aTime[3]], _
        ['Back Bed Room', False, $aTime[4]], _
        ['Bathroom Full', False, $aTime[5]], _
        ['Bathroom Half', False, $aTime[6]], _
        ['Living Room', False, $aTime[7]], _
        ['Dining Bar', False, $aTime[8]], _
        ['Dining Porch', False, $aTime[9]], _
        ['Basement', False, $aTime[10]], _
        ['Garage', False, $aTime[11]], _
        ['Laundry Room', False, $aTime[12]], _
        ['Lawn (Cutting)', False, $aTime[13]], _
        ['Storage', False, $aTime[14]], _
        ['Porch', False, $aTime[15]], _
        ['Closed Porch', False, $aTime[16]], _
        ['Weed Pulling', False, $aTime[17]], _
        ['Misc1', False, $aTime[18]], _
        ['Misc2', False, $aTime[19]], _
        ['Misc3', False, $aTime[20]], _
        ['Misc4', False, $aTime[21]], _
        ['Misc5', False, $aTime[22]]]
;_ArrayDisplay($aChores)


; need
; timer - how long does it take
; choir name
; choir type - full, half, straighten
; week/day
; person name
; calendar
;
CreateSchedule()
; calandar
Func CreateSchedule()
    Local $hMainGui = GUICreate('Chore List', 1200, 525)
    Local $iCountDown = 70
    GUICtrlCreateLabel('Week One', 10, $iCountDown)
    ;
    GUICtrlCreateLabel('Week Two', 10, $iCountDown + 115)
    ;
    GUICtrlCreateLabel('Week Three', 10, $iCountDown + 230)
    ;
    GUICtrlCreateLabel('Week Four', 10, $iCountDown + 345)
    ;
    ;
    Local $iSpace = 155
    GUICtrlCreateLabel('Sunday', $iSpace, 10)
    GUICtrlCreateLabel('Monday', $iSpace * 2, 10)
    GUICtrlCreateLabel('Tuesday', $iSpace * 3, 10)
    GUICtrlCreateLabel('Wednesday', $iSpace * 4, 10)
    GUICtrlCreateLabel('Thursday', $iSpace * 5, 10)
    GUICtrlCreateLabel('Friday', $iSpace * 6, 10)
    GUICtrlCreateLabel('Saturday', $iSpace * 7, 10)
    $iCountDown = 20
    Local $iSideStep = 155

    ;$sComboChores = _ArrayToString($aChores)
    ;#cs
    ; create combo list
    For $x = 1 To UBound($aChores) - 1
        If $x = UBound($aChores) - 1 Then
            $sComboChores &= $aChores[$x][0]
        Else
            $sComboChores &= '|' & $aChores[$x][0];& '|'
        EndIf
    Next
    ;#ce
    ;
    ;
    Local $iJumpDown = 0, $iJumpOver = 0, $iWeek = 1
    For $x = 1 To UBound($aSunday) - 1
        $aSunday[$x][0] = 'Sunday Week' & $iWeek
        For $y = 1 To UBound($aSunday, 2) - 1
            $aSunday[$x][$y] = GUICtrlCreateCombo('', 110, 25 + $iCountDown * 2 + $iJumpDown, 130, 15) ; 105 height
            GUICtrlSetBkColor(-1, '0x00ff00')
            GUICtrlSetData(-1, $sComboChores)
            $iJumpDown += 21
        Next
        $iWeek += 1
        $iJumpDown += 10
    Next
    ;
    ;
    $iJumpDown = 0
    $iWeek = 1
    For $x = 1 To UBound($aMonday) - 1
        $aMonday[$x][0] = 'Monday Week' & $iWeek
        For $y = 1 To UBound($aMonday, 2) - 1
            $aMonday[$x][$y] = GUICtrlCreateCombo('', 110 + $iSideStep, 25 + $iCountDown * 2 + $iJumpDown, 130, 15) ; 105 height
            GUICtrlSetBkColor(-1, '0x00ff00')
            GUICtrlSetData(-1, $sComboChores)
            $iJumpDown += 21
        Next
        $iWeek += 1
        $iJumpDown += 10
    Next
    ;
    ;
    $iJumpDown = 0
    $iWeek = 1
    For $x = 1 To UBound($aTuesday) - 1
        $aTuesday[$x][0] = 'Tuesday Week' & $iWeek
        For $y = 1 To UBound($aTuesday, 2) - 1
            $aTuesday[$x][$y] = GUICtrlCreateCombo('', 110 + $iSideStep * 2, 25 + $iCountDown * 2 + $iJumpDown, 130, 15) ; 105 height
            GUICtrlSetBkColor(-1, '0x00ff00')
            GUICtrlSetData(-1, $sComboChores)
            $iJumpDown += 21
        Next
        $iWeek += 1
        $iJumpDown += 10
    Next
    ;
    ;
    $iJumpDown = 0
    $iWeek = 1
    For $x = 1 To UBound($aWednesday) - 1
        $aWednesday[$x][0] = 'Wednesday Week' & $iWeek
        For $y = 1 To UBound($aWednesday, 2) - 1
            $aWednesday[$x][$y] = GUICtrlCreateCombo('', 110 + $iSideStep * 3, 25 + $iCountDown * 2 + $iJumpDown, 130, 15) ; 105 height
            GUICtrlSetBkColor(-1, '0x00ff00')
            GUICtrlSetData(-1, $sComboChores)
            $iJumpDown += 21
        Next
        $iWeek += 1
        $iJumpDown += 10
    Next
    ;
    ;
    $iJumpDown = 0
    $iWeek = 1
    For $x = 1 To UBound($aThursday) - 1
        $aThursday[$x][0] = 'Thursday Week' & $iWeek
        For $y = 1 To UBound($aThursday, 2) - 1
            $aThursday[$x][$y] = GUICtrlCreateCombo('', 110 + $iSideStep * 4, 25 + $iCountDown * 2 + $iJumpDown, 130, 15) ; 105 height
            GUICtrlSetBkColor(-1, '0x00ff00')
            GUICtrlSetData(-1, $sComboChores)
            $iJumpDown += 21
        Next
        $iWeek += 1
        $iJumpDown += 10
    Next
    ;
    ;
    $iJumpDown = 0
    $iWeek = 1
    For $x = 1 To UBound($aFriday) - 1
        $aFriday[$x][0] = 'Friday Week' & $iWeek
        For $y = 1 To UBound($aFriday, 2) - 1
            $aFriday[$x][$y] = GUICtrlCreateCombo('', 110 + $iSideStep * 5, 25 + $iCountDown * 2 + $iJumpDown, 130, 15) ; 105 height
            GUICtrlSetBkColor(-1, '0x00ff00')
            GUICtrlSetData(-1, $sComboChores)
            $iJumpDown += 21
        Next
        $iWeek += 1
        $iJumpDown += 10
    Next
    ;
    ;
    $iJumpDown = 0
    $iWeek = 1
    For $x = 1 To UBound($aSaturday) - 1
        $aSaturday[$x][0] = 'Saturday Week' & $iWeek
        For $y = 1 To UBound($aSaturday, 2) - 1
            $aSaturday[$x][$y] = GUICtrlCreateCombo('', 110 + $iSideStep * 6, 25 + $iCountDown * 2 + $iJumpDown, 130, 15) ; 105 height
            GUICtrlSetBkColor(-1, '0x00ff00')
            GUICtrlSetData(-1, $sComboChores)
            $iJumpDown += 21
        Next
        $iWeek += 1
        $iJumpDown += 10
    Next
    GUISetState(@SW_SHOW, $hMainGui)

    While 1
        $msg = GUIGetMsg()

        If $msg = $GUI_EVENT_CLOSE Then ExitLoop
        For $x = 1 To UBound($aSunday) - 1
            For $y = 1 To UBound($aSunday, 2) - 1
                If $msg = $aSunday[$x][$y] Then
                    ;UpdateComboList($aSunday)
                    ;UpdateComboList($aMonday)
                    UpdateChoreList('','','')
                    ;UpdateChoreList(GUICtrlRead($aSunday[$x][$y]), $sComboChores) ;MsgBox('', '', GUICtrlRead($aSunday[$x][$y]))
                    ;UpdateChoreList($aSunday[$x][$y], GUICtrlRead($aSunday[$x][$y]), $sComboChores)
                EndIf
            Next
        Next
        ;
        For $x = 1 To UBound($aMonday) - 1
            For $y = 1 To UBound($aMonday, 2) - 1
                If $msg = $aMonday[$x][$y] Then
                    UpdateChoreList('','','')
                    ;UpdateComboList($aMonday)
                    ;UpdateChoreList($aMonday[$x][$y], GUICtrlRead($aMonday[$x][$y]), $sComboChores) ;MsgBox('', '', GUICtrlRead($aMonday[$x][$y]))
                EndIf
            Next
        Next
        ;
        For $x = 1 To UBound($aTuesday) - 1
            For $y = 1 To UBound($aTuesday, 2) - 1
                If $msg = $aTuesday[$x][$y] Then
                    UpdateComboList($aTuesday)
                    ;UpdateChoreList($aTuesday[$x][$y], GUICtrlRead($aTuesday[$x][$y]), $sComboChores) ;MsgBox('', '', GUICtrlRead($aTuesday[$x][$y]))
                EndIf
            Next
        Next
        ;
        For $x = 1 To UBound($aWednesday) - 1
            For $y = 1 To UBound($aWednesday, 2) - 1
                If $msg = $aWednesday[$x][$y] Then
                    UpdateComboList($aWednesday)
                    ;UpdateChoreList($aWednesday[$x][$y], GUICtrlRead($aWednesday[$x][$y]), $sComboChores) ;MsgBox('', '', GUICtrlRead($aWednesday[$x][$y]))
                EndIf
            Next
        Next
        ;
        For $x = 1 To UBound($aThursday) - 1
            For $y = 1 To UBound($aThursday, 2) - 1
                If $msg = $aThursday[$x][$y] Then
                    UpdateComboList($aThursday)
                    ;UpdateChoreList($aThursday[$x][$y], GUICtrlRead($aThursday[$x][$y]), $sComboChores) ;MsgBox('', '', GUICtrlRead($aThursday[$x][$y]))
                EndIf
            Next
        Next
        ;
        For $x = 1 To UBound($aFriday) - 1
            For $y = 1 To UBound($aFriday, 2) - 1
                If $msg = $aFriday[$x][$y] Then
                    UpdateComboList($aFriday)
                    ;UpdateChoreList($aFriday[$x][$y], GUICtrlRead($aFriday[$x][$y]), $sComboChores) ;MsgBox('', '', GUICtrlRead($aFriday[$x][$y]))
                EndIf
            Next
        Next
        ;
        For $x = 1 To UBound($aSaturday) - 1
            For $y = 1 To UBound($aSaturday, 2) - 1
                If $msg = $aSaturday[$x][$y] Then
                    UpdateComboList($aSaturday)
                    ;UpdateChoreList($aSaturday[$x][$y], GUICtrlRead($aSaturday[$x][$y]), $sComboChores) ; MsgBox('', '', GUICtrlRead($aSaturday[$x][$y]))
                EndIf
            Next
        Next
    WEnd

    GUIDelete($hMainGui)

    ;_ArrayDisplay($aSunday)
EndFunc   ;==>CreateSchedule
;
Func UpdateChoreList($hControl, $sDeleteFromList, $sComboChorestemp)
    #cs
    Local $aTempCombo = StringSplit($sComboChorestemp, '|', 2)
    ;_ArrayDisplay($aTempCombo)
    ;_ArrayDisplay($aTempCombo)
    For $x = UBound($aTempCombo) - 1 To 0 Step -1
        If $sDeleteFromList = $aTempCombo[$x] Then
            MsgBox('', '$sDeleteFromList', $sDeleteFromList)
            _ArrayDelete($aTempCombo, $x)
            _ArrayDelete($aChores, $x)
            ExitLoop
        EndIf
    Next
    ;Return

    $sComboChores = ''
    $sComboChores = _ArrayToString($aTempCombo)
    ;GUICtrlSetData($hControl, '')
    ;GUICtrlSetData($hControl, $sComboChores, $sDeleteFromList)
    #ce
    ;UpdateComboList($hControl)

    UpdateComboList($aSunday)
    UpdateComboList($aMonday)
    UpdateComboList($aTuesday)
    UpdateComboList($aWednesday)
    UpdateComboList($aThursday)
    UpdateComboList($aFriday)
    UpdateComboList($aSaturday)



EndFunc   ;==>UpdateChoreList
;

;



Func UpdateComboList($aArray)
    ;MsgBox('','$sComboChores',$sComboChores)
    ;
    ; Capy the original full data string - add final "|" for matching
    Local $sNewString = $sComboChores & "|"


    ;Local $sTempValue = GUICtrlRead($hControl), $sAnother = ''

    ; Now remove all currently selected items
    For $i = 1 To UBound($aArray) - 1
        For $j = 1 To UBound($aArray, 2) - 1
            If GUICtrlRead($aArray[$i][$j]) Then
                $sNewString = StringReplace($sNewString, "|" & GUICtrlRead($aArray[$i][$j]) & "|", "|")
                ConsoleWrite($sNewString)
            EndIf
            ConsoleWrite(@CRLF)
        Next
    Next

    ;MsgBox('','', $sNewString)
    ; Remove final "|"
    $sNewString = StringTrimRight($sNewString, 1)

    ; Change the data for each combo - restoring the currently selected item for those that have one
    For $i = 1 To UBound($aArray) - 1
        For $j = 1 To UBound($aArray, 2) - 1
            $sCurrSel = GUICtrlRead($aArray[$i][$j])
            $sThisString = $sNewString & "|" & $sCurrSel
            ;GUICtrlSetData($aSunday[$i][$j], '')
            GUICtrlSetData($aArray[$i][$j], $sThisString, $sCurrSel)
        Next
    Next
$sComboChores = $sThisString
    #cs
        For $x = 1 To UBound($aSunday) - 1
        For $y = 1 To UBound($aSunday, 2) - 1
        If GUICtrlRead($aSunday[$x][$y]) = '' Then
        GUICtrlSetData($aSunday[$x][$y], '')
        GUICtrlSetData($aSunday[$x][$y], $sComboChores)
        ElseIf GUICtrlRead($aSunday[$x][$y]) <> '' Or GUICtrlRead($hControl) <> '' Then
        If GUICtrlRead($hControl) = GUICtrlRead($aSunday[$x][$y]) Then

        ;GUICtrlSetData($aSunday[$x][$y], $sComboChores, $sTempValue)
        ElseIf GUICtrlRead($aSunday[$x][$y]) <> '' Then
        ConsoleWrite('1 ' & @CRLF)
        $sAnother = GUICtrlRead($aSunday[$x][$y])
        ;
        ;$sComboChores = $sAnother & '|' & $sComboChores
        ;
        GUICtrlSetData($aSunday[$x][$y], '')
        ;GUICtrlSetData($aSunday[$x][$y], $sComboChores)
        GUICtrlSetData($aSunday[$x][$y], $sAnother & '|' & $sComboChores, $sAnother)
        EndIf
        Else

        EndIf
        Next
        Next

        If $sTempValue = GUICtrlRead($aSunday[$x][$y]) Then
        GUICtrlSetData($aSunday[$x][$y], $sComboChores, $sTempValue)
        Else
        Then
        GUICtrlSetData($aSunday[$x][$y], '')
        GUICtrlSetData($aSunday[$x][$y], $sComboChores)
        GUICtrlSetData($aSunday[$x][$y], $sComboChores, $sTempValue)
        ;GUICtrlSetData($aSunday[$x][$y], $sComboChores, $sTempValue)
        Else
        ;GUICtrlSetData($aSunday[$x][$y], '')
        ;GUICtrlSetData($aSunday[$x][$y], $sComboChores)
        EndIf
        EndIf

    #ce
    #cs
        For $x = 1 To UBound($aMonday) - 1
        For $y = 1 To UBound($aMonday, 2) - 1
        If GUICtrlRead($aMonday[$x][$y]) = '' Then
        GUICtrlSetData($aMonday[$x][$y], '')
        GUICtrlSetData($aMonday[$x][$y], $sComboChores)
        Else
        GUICtrlSetData($aMonday[$x][$y], $sComboChores)
        EndIf
        Next
        Next
        For $x = 1 To UBound($aTuesday) - 1
        For $y = 1 To UBound($aTuesday, 2) - 1
        If GUICtrlRead($aTuesday[$x][$y]) = '' Then
        GUICtrlSetData($aTuesday[$x][$y], '')
        GUICtrlSetData($aTuesday[$x][$y], $sComboChores)
        Else
        GUICtrlSetData($aTuesday[$x][$y], $sComboChores)
        EndIf
        Next
        Next
        For $x = 1 To UBound($aWednesday) - 1
        For $y = 1 To UBound($aWednesday, 2) - 1
        If GUICtrlRead($aWednesday[$x][$y]) = '' Then
        GUICtrlSetData($aWednesday[$x][$y], '')
        GUICtrlSetData($aWednesday[$x][$y], $sComboChores)
        Else
        GUICtrlSetData($aWednesday[$x][$y], $sComboChores)
        EndIf
        Next
        Next
        For $x = 1 To UBound($aThursday) - 1
        For $y = 1 To UBound($aThursday, 2) - 1
        If GUICtrlRead($aThursday[$x][$y]) = '' Then
        GUICtrlSetData($aThursday[$x][$y], '')
        GUICtrlSetData($aThursday[$x][$y], $sComboChores)
        Else
        GUICtrlSetData($aThursday[$x][$y], $sComboChores)
        EndIf
        Next
        Next
        For $x = 1 To UBound($aFriday) - 1
        For $y = 1 To UBound($aFriday, 2) - 1
        If GUICtrlRead($aFriday[$x][$y]) = '' Then
        GUICtrlSetData($aFriday[$x][$y], '')
        GUICtrlSetData($aFriday[$x][$y], $sComboChores)
        Else
        GUICtrlSetData($aFriday[$x][$y], $sComboChores)
        EndIf
        Next
        Next
        For $x = 1 To UBound($aSaturday) - 1
        For $y = 1 To UBound($aSaturday, 2) - 1
        If GUICtrlRead($aSaturday[$x][$y]) = '' Then
        GUICtrlSetData($aSaturday[$x][$y], '')
        GUICtrlSetData($aSaturday[$x][$y], $sComboChores)
        Else
        GUICtrlSetData($aSaturday[$x][$y], $sComboChores)
        EndIf
        Next
        Next
    #ce
EndFunc   ;==>UpdateComboList

Thanks again for any help

 


All by me:

"Sometimes you have to go back to where you started, to get to where you want to go." 

"Everybody catches up with everyone, eventually" 

"As you teach others, you are really teaching yourself."

From my dad

"Do not worry about yesterday, as the only thing that you can control is tomorrow."

 

WindowsError.gif

WIKI | Tabs; | Arrays; | Strings | Wiki Arrays | How to ask a Question | Forum Search | FAQ | Tutorials | Original FAQ | ONLINE HELP | UDF's Wiki | AutoIt PDF

AutoIt Snippets | Multple Guis | Interrupting a running function | Another Send

StringRegExp | StringRegExp Help | RegEXTester | REG TUTOR | Reg TUTOT 2

AutoItSetOption | Macros | AutoIt Snippets | Wrapper | Autoit  Docs

SCITE | SciteJump | BB | MyTopics | Programming | UDFs | AutoIt 123 | UDFs Form | UDF

Learning to script | Tutorials | Documentation | IE.AU3 | Games? | FreeSoftware | Path_Online | Core Language

Programming Tips

Excel Changes

ControlHover.UDF

GDI_Plus

Draw_On_Screen

GDI Basics

GDI_More_Basics

GDI Rotate

GDI Graph

GDI  CheckExistingItems

GDI Trajectory

Replace $ghGDIPDll with $__g_hGDIPDll

DLL 101?

Array via Object

GDI Swimlane

GDI Plus French 101 Site

GDI Examples UEZ

GDI Basic Clock

GDI Detection

Ternary operator

Share this post


Link to post
Share on other sites
Melba23

nitekram,

Just how do you want this to work? Obviously the "5-a-day" choices need to be unique, but what about as you proceed through the week? Is it each chore once a week only or can they appear several times? And presumably each week is an entirely separate entity?

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites
nitekram

@M23

All great questions...I will have to think about that, before I ask for your help. I do not want to waste your time, if I later change my mind later - so better make sure what I want first.

I will answer this question tomorrow - thanks for making me think it out.

 


All by me:

"Sometimes you have to go back to where you started, to get to where you want to go." 

"Everybody catches up with everyone, eventually" 

"As you teach others, you are really teaching yourself."

From my dad

"Do not worry about yesterday, as the only thing that you can control is tomorrow."

 

WindowsError.gif

WIKI | Tabs; | Arrays; | Strings | Wiki Arrays | How to ask a Question | Forum Search | FAQ | Tutorials | Original FAQ | ONLINE HELP | UDF's Wiki | AutoIt PDF

AutoIt Snippets | Multple Guis | Interrupting a running function | Another Send

StringRegExp | StringRegExp Help | RegEXTester | REG TUTOR | Reg TUTOT 2

AutoItSetOption | Macros | AutoIt Snippets | Wrapper | Autoit  Docs

SCITE | SciteJump | BB | MyTopics | Programming | UDFs | AutoIt 123 | UDFs Form | UDF

Learning to script | Tutorials | Documentation | IE.AU3 | Games? | FreeSoftware | Path_Online | Core Language

Programming Tips

Excel Changes

ControlHover.UDF

GDI_Plus

Draw_On_Screen

GDI Basics

GDI_More_Basics

GDI Rotate

GDI Graph

GDI  CheckExistingItems

GDI Trajectory

Replace $ghGDIPDll with $__g_hGDIPDll

DLL 101?

Array via Object

GDI Swimlane

GDI Plus French 101 Site

GDI Examples UEZ

GDI Basic Clock

GDI Detection

Ternary operator

Share this post


Link to post
Share on other sites
Melba23

nitekram,

better make sure what I want first

A very good idea! Now if only other posters would adopt the same principle.

M23 


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites
nitekram

Okay, I had a long drive home...I now know what I want - but not sure if possible (may be a bid tedious)

I want the function I call to have a parameter (1, 2, 4) ONE would be each week, TWO would divide the 4 weeks into two sections, and FOUR would be over all 4 weeks.

EDIT

If possible can you comment it, so I can follow the process of your brain?

 

EDIT 2

If the array scheme that I have now makes it harder, I am not worried if it needs to be changed to make it easier. If you need it changed, just let me know, and I will make the change, and repost it.

 

EDIT 3

In fact, I am sure you want me to change it, as I can see it being easier to divide everything into weeks???

Edited by nitekram

All by me:

"Sometimes you have to go back to where you started, to get to where you want to go." 

"Everybody catches up with everyone, eventually" 

"As you teach others, you are really teaching yourself."

From my dad

"Do not worry about yesterday, as the only thing that you can control is tomorrow."

 

WindowsError.gif

WIKI | Tabs; | Arrays; | Strings | Wiki Arrays | How to ask a Question | Forum Search | FAQ | Tutorials | Original FAQ | ONLINE HELP | UDF's Wiki | AutoIt PDF

AutoIt Snippets | Multple Guis | Interrupting a running function | Another Send

StringRegExp | StringRegExp Help | RegEXTester | REG TUTOR | Reg TUTOT 2

AutoItSetOption | Macros | AutoIt Snippets | Wrapper | Autoit  Docs

SCITE | SciteJump | BB | MyTopics | Programming | UDFs | AutoIt 123 | UDFs Form | UDF

Learning to script | Tutorials | Documentation | IE.AU3 | Games? | FreeSoftware | Path_Online | Core Language

Programming Tips

Excel Changes

ControlHover.UDF

GDI_Plus

Draw_On_Screen

GDI Basics

GDI_More_Basics

GDI Rotate

GDI Graph

GDI  CheckExistingItems

GDI Trajectory

Replace $ghGDIPDll with $__g_hGDIPDll

DLL 101?

Array via Object

GDI Swimlane

GDI Plus French 101 Site

GDI Examples UEZ

GDI Basic Clock

GDI Detection

Ternary operator

Share this post


Link to post
Share on other sites
Melba23

nitekram,

Good job it was a rainy afternoon! That was a really fun problem - and I think I have a solution.  Play around with this and see if it does what you want:

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <StaticConstants.au3>
#include <Array.au3>

;         Chore,            interval (1, 2, 4 weeks),   Count in week 1,2,3,4
Global $aChoresBase[][] = [ _
        ['Kitchen',         1,                          0, 0, 0, 0], _
        ['Master Bed Room', 1,                          0, 0, 0, 0], _
        ['Front Bed Room',  2,                          0, 0, 0, 0], _
        ['Back Bed Room',   2,                          0, 0, 0, 0], _
        ['Bathroom Full',   1,                          0, 0, 0, 0], _
        ['Bathroom Half',   2,                          0, 0, 0, 0], _
        ['Living Room',     1,                          0, 0, 0, 0], _
        ['Dining Bar',      1,                          0, 0, 0, 0], _
        ['Dining Porch',    2,                          0, 0, 0, 0], _
        ['Basement',        4,                          0, 0, 0, 0], _
        ['Garage',          4,                          0, 0, 0, 0], _
        ['Laundry Room',    2,                          0, 0, 0, 0], _
        ['Lawn (Cutting)',  2,                          0, 0, 0, 0], _
        ['Storage',         4,                          0, 0, 0, 0], _
        ['Porch',           2,                          0, 0, 0, 0], _
        ['Closed Porch',    2,                          0, 0, 0, 0], _
        ['Weed Pulling',    2,                          0, 0, 0, 0], _
        ['Misc1',           4,                          0, 0, 0, 0], _
        ['Misc2',           4,                          0, 0, 0, 0], _
        ['Misc3',           4,                          0, 0, 0, 0], _
        ['Misc4',           4,                          0, 0, 0, 0], _
        ['Misc5',           4,                          0, 0, 0, 0]]

_ArrayDisplay($aChoresBase, "Original", Default, 8) ; Display only

; Create combo list
$sChoreListBase = ""
For $i = 0 To UBound($aChoresBase) - 1
    $sChoreListBase &= "|" & $aChoresBase[$i][0]
Next

Global $cCombo_Start

CreateSchedule()

Func CreateSchedule()

    Local $hMainGui = GUICreate('Chore List', 1200, 540)

    ; Create labels
    Local $iWeekSpacing = 125, $iWeekOffset = 90
    For $i = 1 To 4
        GUICtrlCreateLabel('Week ' & $i, 10, ($i * $iWeekSpacing) - $iWeekOffset)
    Next
    Local $iDaySpacing = 155, $iDayOffset = 45
    Local $aDay[8] = ["", 'Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday']
    For $i = 1 To 7
        GUICtrlCreateLabel($aDay[$i], $iDaySpacing * ($i) - $iDayOffset, 10, 125, 20, $SS_CENTER)
    Next

    ; Create combos
    $cCombo_Start = GUICtrlCreateDummy() + 1 ; ControlID of first combo
    Local $iComboOffset = 21, $iChoresPerDay = 5
    For $i = 1 To 4 ; Weeks
        $iY_Base = ($i * $iWeekSpacing) - $iWeekOffset
        For $j = 1 To 7 ; Days
            $iX = ($iDaySpacing * $j) - $iDayOffset
            For $k = 0 To $iChoresPerDay - 1 ; Chores
                $iY = $iY_Base + ($iComboOffset * $k)
                GUICtrlCreateCombo("", $iX, $iY, 125, 20)
                GUICtrlSetData(-1, $sChoreListBase)
            Next
        Next
    Next
    $cCombo_End = GUICtrlCreateDummy() - 1 ; ControlID of last combo

    GUISetState()

    While 1
        $iMsg = GUIGetMsg()
        Switch $iMsg
            Case $GUI_EVENT_CLOSE
                Exit
            Case $cCombo_Start To $cCombo_End ; Combo actioned
                _Update_Combos()
        EndSwitch
    WEnd


EndFunc

Func _Update_Combos()

    ; Read data from all combos into new blank chores array
    Local $aChores = $aChoresBase
    For $i = 0 To 3 ; Weeks
        For $j = 0 To 34 ; Combos
            ; Read combo setting - ControlID calculated
            $sSel = GUICtrlRead($cCombo_Start + $j + ($i * 35))
            If $sSel Then
                ; Find index of selected chore in the array
                $iIndex = _ArraySearch($aChores, $sSel)
                ; Set for correct week
                $aChores[$iIndex][$i + 2] += 1
            EndIf
        Next
    Next
    _ArrayDisplay($aChores, "Up To Date", Default, 8) ; Display only

    ; Copy base combo list - one for each week
    Local $aChoreList[5] = ["", $sChoreListBase & "|", $sChoreListBase & "|", $sChoreListBase & "|", $sChoreListBase & "|"]

    ; Now run through chores and decide if interval criteria met
    For $i = 0 To UBound($aChores) - 1
        ; Check required interval
        Switch $aChores[$i][1]
            Case 1 ; Once per week
                For $j = 1 To 4
                    ; So if chosen in this week
                    If $aChores[$i][$j + 1] Then
                        ; Remove from the list for this week only
                        ConsoleWrite("Removing " & $aChores[$i][0] & " from List " & $j & @CRLF)
                        $aChoreList[$j] = StringReplace($aChoreList[$j], "|" & $aChores[$i][0] & "|", "|")
                    EndIf
                Next
            Case 2 ; Once every 2 weeks
                ; Split into 2 x 2-week sections
                For $k = 0 To 2 Step 2
                    ; If chosen in this section
                    $iCount = 0
                    For $j = 1 To 2
                        $iCount += $aChores[$i][$j + $k + 1]
                    Next
                    If $iCount Then
                        $sLists = ( ($k) ? ("3 & 4") : ("1 & 2") )
                        ConsoleWrite("Removing " & $aChores[$i][0] & " from Lists " & $sLists & @CRLF)
                        ; Remove from both lists for this section
                        For $j = 1 + $k To 2 + $k
                            $aChoreList[$j] = StringReplace($aChoreList[$j], "|" & $aChores[$i][0] & "|", "|")
                        Next
                    EndIf
                Next
            Case 4 ; Once every 4 weeks
                ; If chosen
                $iCount = 0
                For $j = 1 To 4
                    $iCount += $aChores[$i][$j + 1]
                Next
                If $iCount Then
                    ; Remove from all lists
                    ConsoleWrite("Removing " & $aChores[$i][0] & " from ALL Lists" & @CRLF)
                    For $j = 1 To 4
                        $aChoreList[$j] = StringReplace($aChoreList[$j], "|" & $aChores[$i][0] & "|", "|")
                    Next
                EndIf
        EndSwitch
    Next
    _ArrayDisplay($aChoreList, "Combo Data Lists", Default, 8) ; Display only

    ; Now fill combos
    For $i = 0 To 3 ; Weeks
        For $j = 0 To 34 ; Combos
            ; Read combo
            $sSel = GUICtrlRead($cCombo_Start + $j + ($i * 35))
            ; Get data string for this week
            $sData = StringTrimRight($aChoreList[$i + 1], 1)
            ; Add current selection if required
            If $sSel Then
                $sData &= "|" & $sSel
            EndIf
            ; Load combo
            GUICtrlSetData($cCombo_Start + $j + ($i * 35), $sData, $sSel)
        Next
    Next

EndFunc

Please do ask if anything is unclear - although I have tried to comment liberally,it is not always easy to make things as clear as they appear to the original coder.

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites
nitekram

First off - I am amazed at how short it is. I know it will work, but I am having an issue running it.

ERROR: (132,23) : ERROR: syntax error (illegal character)

$sLists = (($k) ? ("3 & 4") :("1 & 2"))

I do not know this code, and I tried to do a search in the help file, but that was pointless - can you tell me what this is called?

 

EDIT

I commented out these two line and am starting to play with it - I will be back soon

;$sLists = (($k) ? ("3 & 4") :("1 & 2"))
;ConsoleWrite("Removing " & $aChores[$i][0] & " from Lists " & $sLists & @CRLF)

 

EDIT 2

I actually got that code to work, changed it to - but would still like to learn this new syntax

If $k = 3 Or $k = 4 Then
                            $sLists = "3 & 4"
                        Else
                            $sLists = "1 & 2"
                        EndIf
                        ;$sLists = (($k) ? ("3 & 4") :("1 & 2"))
                        ConsoleWrite("Removing " & $aChores[$i][0] & " from Lists " & $sLists & @CRLF)

Edited by nitekram

All by me:

"Sometimes you have to go back to where you started, to get to where you want to go." 

"Everybody catches up with everyone, eventually" 

"As you teach others, you are really teaching yourself."

From my dad

"Do not worry about yesterday, as the only thing that you can control is tomorrow."

 

WindowsError.gif

WIKI | Tabs; | Arrays; | Strings | Wiki Arrays | How to ask a Question | Forum Search | FAQ | Tutorials | Original FAQ | ONLINE HELP | UDF's Wiki | AutoIt PDF

AutoIt Snippets | Multple Guis | Interrupting a running function | Another Send

StringRegExp | StringRegExp Help | RegEXTester | REG TUTOR | Reg TUTOT 2

AutoItSetOption | Macros | AutoIt Snippets | Wrapper | Autoit  Docs

SCITE | SciteJump | BB | MyTopics | Programming | UDFs | AutoIt 123 | UDFs Form | UDF

Learning to script | Tutorials | Documentation | IE.AU3 | Games? | FreeSoftware | Path_Online | Core Language

Programming Tips

Excel Changes

ControlHover.UDF

GDI_Plus

Draw_On_Screen

GDI Basics

GDI_More_Basics

GDI Rotate

GDI Graph

GDI  CheckExistingItems

GDI Trajectory

Replace $ghGDIPDll with $__g_hGDIPDll

DLL 101?

Array via Object

GDI Swimlane

GDI Plus French 101 Site

GDI Examples UEZ

GDI Basic Clock

GDI Detection

Ternary operator

Share this post


Link to post
Share on other sites
Melba23

nitekram,

it is an example of the ternary operator that was introduced in v3.3.10.0 (23rd December, 2013) - you are obviously a good couple of releases behind me!

Just replace that line by these and all will work as expected:

$sLists = "1 & 2"
If $k Then $sLists = "3 & 4"

And that line is only for display purposes anyway.

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites
nitekram

Okay...I am amazed. This is far more than I wanted, for your thought processes is at a higher level than mine. I never even thought of making each choir like that, where each one will have its own schedule.

I want to thank you...I will come back with questions on how you did something/things. Hope you do not mind me picking your brain?

Got to get some sleep now. Working graveyard is not fun, but at least I have AutoIt to keep me company.


All by me:

"Sometimes you have to go back to where you started, to get to where you want to go." 

"Everybody catches up with everyone, eventually" 

"As you teach others, you are really teaching yourself."

From my dad

"Do not worry about yesterday, as the only thing that you can control is tomorrow."

 

WindowsError.gif

WIKI | Tabs; | Arrays; | Strings | Wiki Arrays | How to ask a Question | Forum Search | FAQ | Tutorials | Original FAQ | ONLINE HELP | UDF's Wiki | AutoIt PDF

AutoIt Snippets | Multple Guis | Interrupting a running function | Another Send

StringRegExp | StringRegExp Help | RegEXTester | REG TUTOR | Reg TUTOT 2

AutoItSetOption | Macros | AutoIt Snippets | Wrapper | Autoit  Docs

SCITE | SciteJump | BB | MyTopics | Programming | UDFs | AutoIt 123 | UDFs Form | UDF

Learning to script | Tutorials | Documentation | IE.AU3 | Games? | FreeSoftware | Path_Online | Core Language

Programming Tips

Excel Changes

ControlHover.UDF

GDI_Plus

Draw_On_Screen

GDI Basics

GDI_More_Basics

GDI Rotate

GDI Graph

GDI  CheckExistingItems

GDI Trajectory

Replace $ghGDIPDll with $__g_hGDIPDll

DLL 101?

Array via Object

GDI Swimlane

GDI Plus French 101 Site

GDI Examples UEZ

GDI Basic Clock

GDI Detection

Ternary operator

Share this post


Link to post
Share on other sites
Melba23

nitekram,

Hope you do not mind me picking your brain?

Of course not - ask away.

M23 


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites
nitekram

Okay, starting with the questions...

First can you explain the thought process in getting the format of the labels and combo boxes - maybe pseudo code of what you are doing. I see what you did, but not sure how you got there - if that makes any sense. I mean you see mine, and how long it took me to copy and paste, and copy and paste, and you get the idea.

Edited by nitekram
spelling

All by me:

"Sometimes you have to go back to where you started, to get to where you want to go." 

"Everybody catches up with everyone, eventually" 

"As you teach others, you are really teaching yourself."

From my dad

"Do not worry about yesterday, as the only thing that you can control is tomorrow."

 

WindowsError.gif

WIKI | Tabs; | Arrays; | Strings | Wiki Arrays | How to ask a Question | Forum Search | FAQ | Tutorials | Original FAQ | ONLINE HELP | UDF's Wiki | AutoIt PDF

AutoIt Snippets | Multple Guis | Interrupting a running function | Another Send

StringRegExp | StringRegExp Help | RegEXTester | REG TUTOR | Reg TUTOT 2

AutoItSetOption | Macros | AutoIt Snippets | Wrapper | Autoit  Docs

SCITE | SciteJump | BB | MyTopics | Programming | UDFs | AutoIt 123 | UDFs Form | UDF

Learning to script | Tutorials | Documentation | IE.AU3 | Games? | FreeSoftware | Path_Online | Core Language

Programming Tips

Excel Changes

ControlHover.UDF

GDI_Plus

Draw_On_Screen

GDI Basics

GDI_More_Basics

GDI Rotate

GDI Graph

GDI  CheckExistingItems

GDI Trajectory

Replace $ghGDIPDll with $__g_hGDIPDll

DLL 101?

Array via Object

GDI Swimlane

GDI Plus French 101 Site

GDI Examples UEZ

GDI Basic Clock

GDI Detection

Ternary operator

Share this post


Link to post
Share on other sites
nitekram

Second...I have not used the Dummy control for quite some time, and only once. What is it and why are you using it? Is that like using an array, without using an array, to be able to get the control IDs handle?


All by me:

"Sometimes you have to go back to where you started, to get to where you want to go." 

"Everybody catches up with everyone, eventually" 

"As you teach others, you are really teaching yourself."

From my dad

"Do not worry about yesterday, as the only thing that you can control is tomorrow."

 

WindowsError.gif

WIKI | Tabs; | Arrays; | Strings | Wiki Arrays | How to ask a Question | Forum Search | FAQ | Tutorials | Original FAQ | ONLINE HELP | UDF's Wiki | AutoIt PDF

AutoIt Snippets | Multple Guis | Interrupting a running function | Another Send

StringRegExp | StringRegExp Help | RegEXTester | REG TUTOR | Reg TUTOT 2

AutoItSetOption | Macros | AutoIt Snippets | Wrapper | Autoit  Docs

SCITE | SciteJump | BB | MyTopics | Programming | UDFs | AutoIt 123 | UDFs Form | UDF

Learning to script | Tutorials | Documentation | IE.AU3 | Games? | FreeSoftware | Path_Online | Core Language

Programming Tips

Excel Changes

ControlHover.UDF

GDI_Plus

Draw_On_Screen

GDI Basics

GDI_More_Basics

GDI Rotate

GDI Graph

GDI  CheckExistingItems

GDI Trajectory

Replace $ghGDIPDll with $__g_hGDIPDll

DLL 101?

Array via Object

GDI Swimlane

GDI Plus French 101 Site

GDI Examples UEZ

GDI Basic Clock

GDI Detection

Ternary operator

Share this post


Link to post
Share on other sites
Melba23

nitekram,

Creating grids of controls

If you ever have to create any controls that are in a regular pattern (the labels and combos in this script are a perfect example) then it is nearly always quicker (and certainly shorter) to do so in a loop and to use an algorithm (short formula) to determine the coordinates of each one as they are created. As the combos are the most complex, let us start with them.

Obviously we need to decide some of the constant values before we begin - the spacing between each column and row, how many in each column and row, etc. Then we need to decide the order in which we want to create them to ease subsequent coding - in this case we were looking to differentiate the weeks, so creating the weeks in succession seemed a good way to go, so we start with the week loop and determine the vertical position of the first combo of each block. The formula is very simple (and used in all 3 loops) - the spacing increases by the same amount for each pass and the offset makes sure the first pass is at the correct value:

For $i = 1 To 4 ; Weeks
  $iY_Base = ($i * $iWeekSpacing) - $iWeekOffset ; These values were already defined when we created the week labels

Now we will be creating 7 blocks of combos, one for each day so we need to create these in succession making another loop inside the first - inside which we determine the horizontal position of each block:

For $j = 1 To 7 ; Days
   $iX = ($iDaySpacing * $j) - $iDayOffset ; Again, these values were determined when we created the day labels.

Finally we need to create a combos in the block - each one will be slightly lower than its predecessor, so we use a final loop to calculate the vertical position based on the initial value we determined in the outer loop above:

For $k = 0 To $iChoresPerDay - 1 ; Chores
    $iY = $iY_Base + ($iComboOffset * $k)

Now we have the X & Y coordinates for each combo and can create it in the correct place.  Here is a short script to show the values inside the loops and the order in which the controls are created (plus their ControlIDs in parentheses - (see below why this is of interest):

#include <GUIConstantsEx.au3>

Local $hMainGui = GUICreate('Chore List', 1200, 540)

GUISetState()

; The constants required
Local $iWeekSpacing = 125, $iWeekOffset = 90
Local $iDaySpacing = 155, $iDayOffset = 45
Local $iComboOffset = 21, $iChoresPerDay = 5

; The 3 loops
For $i = 1 To 4 ; Weeks
    $iY_Base = ($i * $iWeekSpacing) - $iWeekOffset
    For $j = 1 To 7 ; Days
        $iX = ($iDaySpacing * $j) - $iDayOffset
        For $k = 0 To $iChoresPerDay - 1 ; Chores
            $iY = $iY_Base + ($iComboOffset * $k)
            $cCID = GUICtrlCreateLabel("", $iX, $iY, 125, 20)
            GUICtrlSetData($cCID, $i & " - " & $j & " - " & $k & " > (" & $cCID & ")")
            GUICtrlSetBkColor($cCID, 0xFFCCCC)
            Sleep(100)
        Next
    Next
Next

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
WEnd

Dummy Controls

Dummies can be very useful - in this script we use them to determine the values of the first and last combos created as the dummies obviously have the ControlIDs just before/after the first/last combo created. This is a trick which only works because AutoIt normally assigns the ControlIDs in numerical succession (it can fail to do this if controls have previously been created and deleted, but that is not the case here) which enables us to loop through the controls one by one. Remember that I mentioned above we wanted to  divide the controls into weeks in the outer loop? As a result the ControlIDs run as you can see in the example above: n to n+34 in the first week, n+35 to n+69 in the second, and so on - and it is now easy to loop through each week's set of combos when deciding whether a certain value has been set.

I hope that is sufficiently clear - please ask again if not.

M23

 


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites
nitekram

M23,

I may be going back to some older scripts and doing a redesign...I think this part that you wrote, should some how make it the help file or something, as it would help others as well. As far as learning this...I guess it is the algorithm, that is stumping me. How do you go about creating/solving it, and knowing when to use it?

And I again, thank you for your time, explaining this layout to me...I do believe that example that you wrote is just, well beautiful.

I now have to get some good questions about the refresh of the combos - after trying to figure it out. I will be back lol

 


All by me:

"Sometimes you have to go back to where you started, to get to where you want to go." 

"Everybody catches up with everyone, eventually" 

"As you teach others, you are really teaching yourself."

From my dad

"Do not worry about yesterday, as the only thing that you can control is tomorrow."

 

WindowsError.gif

WIKI | Tabs; | Arrays; | Strings | Wiki Arrays | How to ask a Question | Forum Search | FAQ | Tutorials | Original FAQ | ONLINE HELP | UDF's Wiki | AutoIt PDF

AutoIt Snippets | Multple Guis | Interrupting a running function | Another Send

StringRegExp | StringRegExp Help | RegEXTester | REG TUTOR | Reg TUTOT 2

AutoItSetOption | Macros | AutoIt Snippets | Wrapper | Autoit  Docs

SCITE | SciteJump | BB | MyTopics | Programming | UDFs | AutoIt 123 | UDFs Form | UDF

Learning to script | Tutorials | Documentation | IE.AU3 | Games? | FreeSoftware | Path_Online | Core Language

Programming Tips

Excel Changes

ControlHover.UDF

GDI_Plus

Draw_On_Screen

GDI Basics

GDI_More_Basics

GDI Rotate

GDI Graph

GDI  CheckExistingItems

GDI Trajectory

Replace $ghGDIPDll with $__g_hGDIPDll

DLL 101?

Array via Object

GDI Swimlane

GDI Plus French 101 Site

GDI Examples UEZ

GDI Basic Clock

GDI Detection

Ternary operator

Share this post


Link to post
Share on other sites
Melba23

nitekram,

The algorithm is in fact very simple - increase a parameter each time you go through a loop - but the trick is doing it in 2/3D as we do here. You can use it whenever you have to create controls in some form of pattern (it is particularly well-suited to grids) where the spacing can be calculated by a simple formula. As to the actual formula - I try and work it out in paper first and then run a simulation script to test that the values I have chosen actually work. And of course, you will nearly always need some form of constant to adjust for the initial position - even Einstein needed one of those, so I have no problem doing the same.

Standing by for the "combo refresh" questions!

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites
nitekram

M23,

I think I will stay away from learning gravity, until I am older, as I will be even closer to the ground - Einstein created a constant in space, so I guess I can start making things up, and only crap my pants, if someone asks me to prove it lol

Okay, I see these offsets are coming in handy, as you also are using them to get past the array indexes that are not part of the loop - I am learning more everyday!

I got all the way to the second case (split into 2 weeks) statement - with understanding, but I am lost...there is a lot going on. May we start with the $iCount, and how it comes into play, I mean my mind is hurting trying to figure it out - LET ALONE how would I begin to even think this way and write it.


All by me:

"Sometimes you have to go back to where you started, to get to where you want to go." 

"Everybody catches up with everyone, eventually" 

"As you teach others, you are really teaching yourself."

From my dad

"Do not worry about yesterday, as the only thing that you can control is tomorrow."

 

WindowsError.gif

WIKI | Tabs; | Arrays; | Strings | Wiki Arrays | How to ask a Question | Forum Search | FAQ | Tutorials | Original FAQ | ONLINE HELP | UDF's Wiki | AutoIt PDF

AutoIt Snippets | Multple Guis | Interrupting a running function | Another Send

StringRegExp | StringRegExp Help | RegEXTester | REG TUTOR | Reg TUTOT 2

AutoItSetOption | Macros | AutoIt Snippets | Wrapper | Autoit  Docs

SCITE | SciteJump | BB | MyTopics | Programming | UDFs | AutoIt 123 | UDFs Form | UDF

Learning to script | Tutorials | Documentation | IE.AU3 | Games? | FreeSoftware | Path_Online | Core Language

Programming Tips

Excel Changes

ControlHover.UDF

GDI_Plus

Draw_On_Screen

GDI Basics

GDI_More_Basics

GDI Rotate

GDI Graph

GDI  CheckExistingItems

GDI Trajectory

Replace $ghGDIPDll with $__g_hGDIPDll

DLL 101?

Array via Object

GDI Swimlane

GDI Plus French 101 Site

GDI Examples UEZ

GDI Basic Clock

GDI Detection

Ternary operator

Share this post


Link to post
Share on other sites
Melba23

nitekram,

Let us take the whole function (which is called each time a combo is actioned) and break it down:

First we create a copy of the $aChores array so we can see what is and is not set this time around.

Then we read all the combos - see how we can read each week in turn by running through in sections of 35. Then if there is a value already set, we find the element of the $aChores array that matches the selected chore and set the correct "week" element (which we can easily calculate from the week number). Now we will have the array filled with all the currently selected chores and the weeks in which they have been selected.

We then create a $aChoreList array with each week being given a full list of the chores to carry out - we need to have 4 as some chores are weekly and might still be selectable in other weeks. The next task is to remove from each list those chores which are already being carried out - so first we need to check how often the chores need to be done: once a week means remove from that week only; every 2 weeks means removes from a 2 week block if already done; while every 4 weeks means remove from all of  lists. We run through each chore in turn and Switch depending on the frequency set (1, 2, 4).

- If 1 (each week) then we look at each week in turn to see if that chore is already selected - the "week" element of the $aChores array will have been set if it is - and if so, remove that chore from that week's list in the $aChoreList array.

- If 2 (every 2 weeks) then we need to look at 2-week blocks (1-2 & 3-4) - and we use 2 loops to do this. The outer loop runs twice with values of 0 and 2, while the inner runs twice from 1 to 2. Adding them means we get the values 1, 2, 3, 4 which nicely matches the week numbering. Inside the 2 loops we check both of the "week" elements of the $aChores array for the 2-week block and if the chore is selected, remove it from both of the lists for those weeks in the $aChoreList array.

- If every 4 weeks then the problem becomes a little simpler - we need a single loop to check each of the "week" elements of the $aChores array and if the chore is set, remove it from all of the lists in the $aChoreList array.

We now have the $aChoreList array filled with 4 lists of the remaining chores for each week. We run yet another loop to fill each week's combos with their respective list - not forgetting to add back the currently displayed value and set it as the default.

And Robert is your mother's brother! Does that make the script clearer?

As to the thought processes I used to develop this - it is mostly a question of logic.  I will try and reconstruct what I did.

You wanted to have 1,2,4 week intervals which forces us to store the required interval, so why not in the same array as the chores themselves?  Using this same array to store the chores already selected in each week is therefore a sensible choice as it keeps everything together.

The next step follows on from something I learnt a long time ago and which I pass on with pleasure. When faced with a long repetitive task (such as which combos need changing) humans tend to look for the changes so as to minimize the number of times things need to be done.  However, computers are usually faster running the whole list of tasks as that means there are fewer conditional statements to run for each item - and they are usually so fast that humans do not notice the passage of time required in any event. So when a combo is actioned we do not look at that particular combo, we just read the whole set and recalculate and reset the combo contents for the entire GUI.  It seems illogical, but believe me it is usually by far the best and fastest way to go about things.

The chore removal logic is the same as I developed for your first query - just expanded to cater for the fact that we have 4 separate lists for the 4 weeks. As I have mentioned previously, choosing the right data structure and loop elements initially makes subsequent coding easier - this is I am afraid mostly (painfully gained) experience and there is no magic formula. But I would stress that it often pays to go back and completely restructure your initial data storage and various loop parameters if by so doing you can make the intensive parts of the script easier to code - the time spent is well worth it in terms of clarity of code and speed of execution.

So there you have it - any more questions?

M23

 


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
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

  • Similar Content

    • odaylton
      By odaylton
      Hello everyone ,
      Text translated from Portuguese by google - please apologize for any errors

      Once again I need a light from the gurus of this wonderful website
      I am fanatic by combobox for its usability but I am not able to uncertain images within lists ...
      I know uncertain icons, and cursors but I am not able to insert gif or jpg images.
      1) How to solve this ...
      2) will the path is to convert gif into bmp and then uncertain ... how to do that?
      #include <GUIConstantsEx.au3> #include <GuiImageList.au3> #include <GuiListView.au3> #include <WinAPI.au3> #include <WindowsConstants.au3> ;dados de mouse #include <WinAPIRes.au3> ;COMBO #include <GuiComboBoxEx.au3> ;Fonts #include <FontConstants.au3> ;obter imagem de arquivo #include <GDIPlus.au3> #include <WinAPIGdi.au3> Example() Func Example() Local $hGUI, $hImage, $hCombo, $hFont Local $idListview, $hImage Local $sWow64 = "" Local $Pasta = "C:\WINDOWS\Cursors\3dgarro.cur" Local $PastaROMs = @MyDocumentsDir & "\Stella\ROMs\" ;com barra no final $hGUI = GUICreate("ImageList", 500, 310) GUISetFont(14, 400, 0, "Arial") ;<<<<<<<<<<this does not work for _GUICtrlComboBoxEx_Create $hCombo = _GUICtrlComboBoxEx_Create($hGUI, "", 2, 2, 494, 200) ;GUICtrlSetFont($hCombo, 14, 400, 0, "Arial");<<<<<<<<<<It does not work ; ;Create a handle to a font object $hFont = _WinAPI_CreateFont(30, 0, 0, 0, 400, False, False, False, $DEFAULT_CHARSET, $OUT_DEFAULT_PRECIS, $CLIP_DEFAULT_PRECIS, $DEFAULT_QUALITY, 0, 'Arial') ;Pass the handle to _WinAPI_SetFont _WinAPI_SetFont($hCombo, $hFont) $idListview = GUICtrlCreateListView("", 2, 50, 494, 250, BitOR($LVS_SHOWSELALWAYS, $LVS_NOSORTHEADER, $LVS_REPORT)) _GUICtrlListView_SetExtendedListViewStyle($idListview, BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_GRIDLINES, $LVS_EX_DOUBLEBUFFER)) GUISetState(@SW_SHOW) ; Initialize GDI+ library _GDIPlus_Startup() ; Load images $hImage = _GUIImageList_Create(120, 70, 6, 2) ;32,32,5,5) ; $DadosCombo = "Escolha|" & _GUIImageList_Add($hImage, _GUICtrlComboBoxEx_CreateSolidBitMap($hCombo, 0x0000FF, 120, 70)) ;Local $aCursors[] = [32650, 32512, 32515, 32649, 32651, 32513, 32648, 32646, 32643, 32645, 32642, 32644, 32516, 32514] For $i = 1 To 10 $sFile = FileOpenDialog("Please select an image", $PastaROMs, "Image (*.jpg;*.png;*.bmp;*.gif;*.tif)", BitOR($FD_PATHMUSTEXIST, $FD_FILEMUSTEXIST)) If @error Then Exit MsgBox(BitOR($MB_TOPMOST, $MB_ICONERROR), "Error", "No image file has been selected", 30) $a = _GDIPlus_BitmapCreateFromFile ($sFile);<<<<< ok If @error Or Not $hImage Then MsgBox(BitOR($MB_TOPMOST, $MB_ICONERROR), "Error", "This file isn't supported by GDIPlus!") Else $b=_GUIImageList_Add($hImage, $a);<<<<<< Return -1 $DadosCombo &= "|" & $i & "_img_princ.gif""|" & $b EndIf Next _GUICtrlListView_SetImageList($idListview, $hImage, 1) _GUICtrlComboBoxEx_SetImageList($hCombo, $hImage) ; Add columns _GUICtrlListView_AddColumn($idListview, "Icons - Mouses", 350) ; Add items $a = StringSplit($DadosCombo, "|") For $i = 1 To $a[0] Step 2 _GUICtrlListView_AddItem($idListview, $a[$i], $a[$i + 1]) _GUICtrlComboBoxEx_AddString($hCombo, $a[$i], $a[$i + 1], $a[$i + 1]) Next ;AutoIt_Debugger_Command:Disable_Debug ; Loop until the user exits. Do Until GUIGetMsg() = $GUI_EVENT_CLOSE GUIDelete() ;AutoIt_Debugger_Command:Enable_Debug EndFunc ;==>Example tks
    • aiter
      By aiter
      I  possibly misunderstood the value of combo boxes, but I thought you could type a value, press enter and the combo box would store that value.
      The reason for wanting this is to store a history of typed commands into the combo box (accepted by pressing enter).
       
      After hours of trying to trap enter on a combobox I realized that the enter event was not registering.
      I had code like this (which used to work on a input box), but it does not for a combobox (because it does not accept enter)
      unc WM_COMMAND($hWnd, $Msg, $wParam, $lParam) Local $nNotifyCode = BitShift($wParam, 16) Local $nID = BitAND($wParam, 0x0000FFFF) If $hWnd = $CmdForm Then If $nID = $ComboInput Then ; useed to work on a normal input box If _IsPressed('0D') Then ; enter was pressed, respond DoCmd() Anyone able to help?
    • Grasoft
      By Grasoft
      Greetings everyone,
      I'm writing a software that edit an ini file section by section with adding/renaming abilities
      but whenever I manually change the combobox to value other than constducted previously, I cannot get this value.
      THIS is a clean version of the code:
      #include <ButtonConstants.au3> #include <ComboConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <GuiStatusBar.au3> #include <GuiEdit.au3> #include <MsgBoxConstants.au3> #Region ### START Koda GUI section ### Form=C:\Program Files (x86)\AutoIt3\SciTE\Koda\Forms\QuickRepEditList7.kxf $SecMgr = GUICreate("Sections Manager", 1159, 690) GUISetFont(12, 800, 0, "MS Sans Serif") $EditSec = GUICtrlCreateEdit("", 45, 45, 1090, 644, BitOR($ES_AUTOVSCROLL, $ES_AUTOHSCROLL, $ES_WANTRETURN, $WS_HSCROLL, $ES_NOHIDESEL)) $Edit2 = GUICtrlCreateEdit("", 11, 45, 33, 617, BitOR($ES_RIGHT, $ES_READONLY, $ES_WANTRETURN)) GUICtrlSetData(-1, StringFormat(" 1:\r\n 2:\r\n 3:\r\n 4:\r\n 5:\r\n 6:\r\n 7:\r\n 8:\r\n 9:\r\n10:\r\n11:\r\n12:\r\n13:\r\n14:\r\n15:\r\n16:\r\n17:\r\n18:\r\n19:\r\n20:\r\n21:\r\n22:\r\n23:\r\n24:\r\n25:\r\n26:\r\n27:\r\n28:\r\n29:\r\n30:")) $Label1 = GUICtrlCreateLabel("Select Section:", 7, 13, 126, 24) GUICtrlSetFont(-1, 11, 800, 0, "MS Sans Serif") $Savesec = GUICtrlCreateButton("Save Changes", 375, 7, 129, 33) $NewSec = GUICtrlCreateButton("New Section", 700, 7, 121, 33) $SecDwn = GUICtrlCreateButton("Section Down", 830, 7, 137, 33) $SecUp = GUICtrlCreateButton("Section Up", 980, 7, 129, 33) $copystrs = GUICtrlCreateButton("*******", 507, 7, 73, 33) GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif") $HeavySep = GUICtrlCreateButton("====", 581, 7, 73, 33) GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif") Global $SecSel Global $secno Global $secn = "NULLz" Global $sFilePathtemp Global $aArray Global $SecNames Global $secnnew Global $ssecn $SecSel = GUICtrlCreateCombo("", 110, 10, 257, 25, BitOR($CBS_DROPDOWN, $CBS_AUTOHSCROLL)) queysecs() Filledit() GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### $secno=GUICtrlRead($SecSel) $changed=0 While 1 $secn = GUICtrlRead($SecSel) $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE saveeditedmsg() Exit Case $SecSel $secno=GUICtrlRead($SecSel) queysecs() Filledit() Case $Savesec saveeditedmsg() queysecs() Case $NewSec Case $SecDwn Case $SecUp Case $copystrs ClipPut("**************************************************************************************************************************************************************") Case $HeavySep ClipPut("==============================================================================================================================================================") EndSwitch WEnd Func queysecs();query section names $sFilePath = @ScriptDir & "\" & "Txt_Reps.ini" $aArray = IniReadSectionNames($sFilePath) $SecNames = $aArray[1] If $secn = "NULLz" Then $secn = $aArray[1] EndIf If Not @error Then For $i = 2 To $aArray[0] $SecNames = $SecNames & "|" & $aArray[$i] Next GUICtrlSetData($SecSel, "", "") GUICtrlSetData($SecSel, $SecNames, $secn) $secno = $secn EndIf EndFunc ;==>queysecs Func Filledit(); transfer section values on the edit box GUICtrlSetData($EditSec, "") $sFilePath = @ScriptDir & "\" & "Txt_Reps.ini" For $i = 1 To 30 $sRead = IniRead($sFilePath, $secn, $i, "") GUICtrlSetData($EditSec, $sRead & @CRLF, 1) Next GUISetState(@SW_SHOW) EndFunc ;==>Filledit Func saveeditedmsg(); save or rename modified section If $secn <> $secno Then $iMsgBoxAnswer = MsgBox(3, "NEW/RENAME", "Press YES to Add this as NEW section" & @CRLF & "Press NO to rename and save this section from " & $secno & "To" & $secn) Select Case $iMsgBoxAnswer = 6 ;YES $secn = $secno save($secn) $secn = GUICtrlRead($SecSel) $secno = $secn Case 7 ;NO $sFilePath = @ScriptDir & "\" & "Txt_Reps.ini" IniRenameSection($sFilePath, $secno, $secn) save($secn) $secn = GUICtrlRead($SecSel) $secno = $secn EndSelect Else $iMsgBoxAnswer = MsgBox(4, "Do you want to save changes to this section", "Save Section: " & $secn) Select Case $iMsgBoxAnswer = 6 ;yes save($secn) EndSelect EndIf EndFunc ;==>saveeditedmsg ;MsgBox(4, "Do you want to add this to Database?",$secn) Func save($ssecn); save edit control to a file and then rewrite modified values by line order. $sFilePathtemp = FileOpen(@ScriptDir & "\" & "tempo.quickrep", $FO_READ + $FO_OVERWRITE + $FO_CREATEPATH + $FO_UTF8) $sFilePath = @ScriptDir & "\" & "Txt_Reps.ini" FileWrite($sFilePathtemp, GUICtrlRead($EditSec)) $sFilePathtemp = FileOpen(@ScriptDir & "\" & "tempo.quickrep", $FO_READ + $FO_UTF8) For $i = 1 To 30 $sRead = FileReadLine($sFilePathtemp, $i) IniWrite($sFilePath, $ssecn, $i, $sRead) Next GUISetState(@SW_SHOW) EndFunc ;==>save And this is with som test msg boxes to know how to get it
      #include <ButtonConstants.au3> #include <ComboConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <GuiStatusBar.au3> #include <GuiEdit.au3> #include <MsgBoxConstants.au3> #Region ### START Koda GUI section ### Form=C:\Program Files (x86)\AutoIt3\SciTE\Koda\Forms\QuickRepEditList7.kxf $SecMgr = GUICreate("Sections Manager", 1159, 690) GUISetFont(12, 800, 0, "MS Sans Serif") $EditSec = GUICtrlCreateEdit("", 45, 45, 1090, 644, BitOR($ES_AUTOVSCROLL, $ES_AUTOHSCROLL, $ES_WANTRETURN, $WS_HSCROLL, $ES_NOHIDESEL)) $Edit2 = GUICtrlCreateEdit("", 11, 45, 33, 617, BitOR($ES_RIGHT, $ES_READONLY, $ES_WANTRETURN)) GUICtrlSetData(-1, StringFormat(" 1:\r\n 2:\r\n 3:\r\n 4:\r\n 5:\r\n 6:\r\n 7:\r\n 8:\r\n 9:\r\n10:\r\n11:\r\n12:\r\n13:\r\n14:\r\n15:\r\n16:\r\n17:\r\n18:\r\n19:\r\n20:\r\n21:\r\n22:\r\n23:\r\n24:\r\n25:\r\n26:\r\n27:\r\n28:\r\n29:\r\n30:")) $Label1 = GUICtrlCreateLabel("Select Section:", 7, 13, 126, 24) GUICtrlSetFont(-1, 11, 800, 0, "MS Sans Serif") $Savesec = GUICtrlCreateButton("Save Changes", 375, 7, 129, 33) $NewSec = GUICtrlCreateButton("New Section", 700, 7, 121, 33) $SecDwn = GUICtrlCreateButton("Section Down", 830, 7, 137, 33) $SecUp = GUICtrlCreateButton("Section Up", 980, 7, 129, 33) ;$LineNo = GUICtrlCreateInput("LineNo", 664, 7, 65, 28) $copystrs = GUICtrlCreateButton("*******", 507, 7, 73, 33) GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif") $HeavySep = GUICtrlCreateButton("====", 581, 7, 73, 33) GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif") Global $SecSel Global $secno Global $secn = "NULLz" Global $sFilePathtemp Global $aArray Global $SecNames Global $secnnew Global $ssecn $SecSel = GUICtrlCreateCombo("", 110, 10, 257, 25, BitOR($CBS_DROPDOWN, $CBS_AUTOHSCROLL)) queysecs() Filledit() GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### $secno=GUICtrlRead($SecSel) $changed=0 While 1 $secn = GUICtrlRead($SecSel) ;If $secn <> $secno and $changed=0 Then ; $secns = $secn ; $changed=1 ;EndIf $nMsg = GUIGetMsg() ;MsgBox(4, "TEST1?", $secn) Switch $nMsg Case $GUI_EVENT_CLOSE saveeditedmsg() Exit Case $SecSel ;MsgBox(4, "TEST?", GUICtrlRead($SecSel)) ;MsgBox(4, "TEST1?", $secns) ;MsgBox(4, "TEST2?", $secn) $secno=GUICtrlRead($SecSel) ;saveeditedmsg() queysecs() Filledit() ;$changed=0 Case $Savesec saveeditedmsg() queysecs() Case $NewSec Case $SecDwn Case $SecUp Case $copystrs ClipPut("**************************************************************************************************************************************************************") Case $HeavySep ClipPut("==============================================================================================================================================================") EndSwitch ; MsgBox(4, "TEST2?", $secn) WEnd Func queysecs();query section names $sFilePath = @ScriptDir & "\" & "Txt_Reps.ini" $aArray = IniReadSectionNames($sFilePath) $SecNames = $aArray[1] ; MsgBox(4, "test3?", $secn) If $secn = "NULLz" Then $secn = $aArray[1] EndIf If Not @error Then For $i = 2 To $aArray[0] $SecNames = $SecNames & "|" & $aArray[$i] Next GUICtrlSetData($SecSel, "", "") GUICtrlSetData($SecSel, $SecNames, $secn) $secno = $secn ;MsgBox(4, "test4?", $secn) EndIf EndFunc ;==>queysecs Func Filledit(); transfer section values on the edit box GUICtrlSetData($EditSec, "") $sFilePath = @ScriptDir & "\" & "Txt_Reps.ini" For $i = 1 To 30 $sRead = IniRead($sFilePath, $secn, $i, "") GUICtrlSetData($EditSec, $sRead & @CRLF, 1) Next GUISetState(@SW_SHOW) EndFunc ;==>Filledit Func saveeditedmsg(); save or rename modified section If $secn <> $secno Then $iMsgBoxAnswer = MsgBox(3, "NEW/RENAME", "Press YES to Add this as NEW section" & @CRLF & "Press NO to rename and save this section from " & $secno & "To" & $secn) Select Case $iMsgBoxAnswer = 6 ;YES $secn = $secno save($secn) $secn = GUICtrlRead($SecSel) $secno = $secn Case 7 ;NO $sFilePath = @ScriptDir & "\" & "Txt_Reps.ini" IniRenameSection($sFilePath, $secno, $secn) save($secn) $secn = GUICtrlRead($SecSel) $secno = $secn EndSelect Else $iMsgBoxAnswer = MsgBox(4, "Do you want to save changes to this section", "Save Section: " & $secn) Select Case $iMsgBoxAnswer = 6 ;yes save($secn) EndSelect EndIf EndFunc ;==>saveeditedmsg ;MsgBox(4, "Do you want to add this to Database?",$secn) Func save($ssecn); save edit control to a file and then rewrite modified values by line order. $sFilePathtemp = FileOpen(@ScriptDir & "\" & "tempo.quickrep", $FO_READ + $FO_OVERWRITE + $FO_CREATEPATH + $FO_UTF8) $sFilePath = @ScriptDir & "\" & "Txt_Reps.ini" FileWrite($sFilePathtemp, GUICtrlRead($EditSec)) $sFilePathtemp = FileOpen(@ScriptDir & "\" & "tempo.quickrep", $FO_READ + $FO_UTF8) For $i = 1 To 30 $sRead = FileReadLine($sFilePathtemp, $i) IniWrite($sFilePath, $ssecn, $i, $sRead) Next GUISetState(@SW_SHOW) EndFunc ;==>save The ini file withthe au3 attached
      This is how I want: when the user changes the combo, the script will check the text combo. In case of changed text it will ask user if I should rename or add it as a new section and then save. If not changed the text of combo it will ask to save only.
      IF NOT possible, Will it possible with _GUICtrlComboBox__GUICtrlComboBoxEx_Create or _GUICtrlComboBoxEx_Create or not
       
      THANK you very much in advance
      QuickSecEdit.zip
    • Ascer
      By Ascer
      1. Description.
      Udf working with MSDN System.Collections.ArrayList. Allow you to make fast operations on huge arrays, speed is even x10 better than basic _ArrayAdd.  Not prefered for small arrays < 600 items. 2. Requirements
      .NET Framework 1.1 - 4.5 (on this version Microsoft destroy old rules) System Windows 3. Possibilities.
      ;=============================================================================================================== ; UDF Name: List.au3 ; ; Date: 2018-02-17, 10:52 ; Description: Simple udf to create System Collections as ArrayList and make multiple actions on them. ; ; Function(s): _ListCreate -> Creates a new list ; _ListCapacity -> Gets a list size in bytes ; _ListCount -> Gets items count in list ; _ListIsFixedSize -> Get bool if list if fixed size ; _ListIsReadOnly -> Get bool if list is read only ; _ListIsSynchronized -> Get bool if list is synchronized ; _ListGetItem -> Get item on index ; _ListSetItem -> Set item on index ; ; _ListAdd -> Add item at end of list ; _ListClear -> Remove all list items ; _ListClone -> Duplicate list in new var ; _ListContains -> Get bool if item is in list ; _ListGetHashCode -> Get hash code for list ; _ListGetRange -> Get list with items between indexs ; _ListIndexOf -> Get index of item ; _ListInsert -> Insert a new item on index ; _ListInsertRange -> Insert list into list on index ; _ListLastIndexOf -> Get index last of item ; _ListRemove -> Remove first found item ; _ListRemoveAt -> Remove item in index ; _ListRemoveRange -> Remove items between indexs ; _ListReverse -> Reverse all items in list ; _ListSetRange -> Set new value for items in range ; _ListSort -> Sort items in list (speed of reading) ; _ListToString -> Get list object name ; _ListTrimToSize -> Remove unused space in list ; ; Author(s): Ascer ;=============================================================================================================== 4. Downloads
      List.au3 5. Examples
      SpeedTest _ArrayAdd vs ListAdd SpeedTest ArraySearch vs ListIndexOf Basic usage - crating guild with members  
    • nacerbaaziz
      By nacerbaaziz
      Hi dears
      how are you? I hope You fine
      I have a question please
      I've created a listView
      It has several columns
      Is there any way  to search for text in an element of this list with text in all columns
      for example
      list view with 2 column
      the first is the file name and the second is the file path
      and i want to search for the item witch Containt the name and the path toGether
      I searched a lot but could not find what I was looking for
      If you do not understand the idea that I'm looking for, I can put an example
      Thanks in advance
×