Sign in to follow this  
Followers 0
joeloyzaga

multi select listbox

10 posts in this topic

I'm sorry but all the examples I have searched and found are too complex for me to understand. Can anyone show me an example of a multi select list - the list is ideally all the rows of an excel spreadsheet but only col1 - so if there are 3 rows the I just want the selectable list just to have 3 selectable items each being row 1-3, col1.

Can someone please run through it and explain please ?

Joe

And Thanks in advance

Share this post


Link to post
Share on other sites



joeloyzaga,

This is a commented script using a multi-select ListBox. Click on a list item to select it - holding control permits multiple selections. The selected items are shown in the SciTE console:

#include <GUIConstantsEx.au3>
#Include <GuiListBox.au3>

; Create array - you would do this using the Excel UDFs
Global $aArray[6]

For $i = 1 to 5
    $aArray[$i] = "Something from Excel " & $i - 1
Next
$aArray[0] = 5

; Create a GUI
$hGUI = GUICreate("MultiSelect ListBox", 300, 250)

$hListBox = _GUICtrlListBox_Create ($hGUI, "", 10, 10, 280, 180, $LBS_EXTENDEDSEL)
$hButton_Select = GUICtrlCreateButton("Select", 30, 210, 80, 30)
$hButton_Clear  = GUICtrlCreateButton("Clear", 190, 210, 80, 30)

GUISetState()

; Load ListBox with the array contents
_Update_ListBox()

While 1

; Poll the GUI
    Switch GUIGetMsg()
    ; Exit
        Case $GUI_EVENT_CLOSE
            Exit
    ; Select button pressed
        Case $hButton_Select
            $aSelected = _GUICtrlListBox_GetSelItems($hListBox)
        ; Write selected items to console
            For $i = 1 To $aSelected[0]
                ConsoleWrite("Item " & $aSelected[$i] & " selected" & @CRLF)
            Next
            ConsoleWrite(@CRLF)
        ; Use the next case code to clear and reload the ListBox
            ContinueCase
    ; Clear button pressed
        Case $hButton_Clear
        ; Clear the items to remove selection status
            _GUICtrlListBox_ResetContent($hListBox)
        ; Reload ListBox
            _Update_ListBox()
            
    EndSwitch
    
; Set item to Selected when given focus by a mouse click - if not already done
    $iIndex = _GUICtrlListBox_GetCaretIndex($hListBox)
    If _GUICtrlListBox_GetSel($hListBox, $iIndex) = False Then _GUICtrlListBox_SetSel($hListBox, $iIndex)

WEnd

Func _Update_ListBox()
    
    _GUICtrlListBox_BeginUpdate($hListBox)
    _GUICtrlListBox_ResetContent($hListBox)
    _GUICtrlListBox_InitStorage($hListBox, 100, 4096)
;_GUICtrlListBox_AddString ($hListBox, "")
    For $i = 1 To $aArray[0]
        _GUICtrlListBox_AddString ($hListBox, $aArray[$i]) 
    Next
    _GUICtrlListBox_EndUpdate($hListBox)

EndFunc

I do not use the Excel UDF (because I do not have Excel!), but from the Help file this looks as if it should work:

#Include <Excel.au3>
#include <Array.au3>

; Open an Excel file - set to not visible and read-only
$oExcel = _ExcelBookOpen($sFilePath, 0, True)

; Move to correct sheet
_ExcelSheetActivate($oExcel, $vSheet)

; Read in cells
; Initialise an array
Global $aArray[1]
; Work down sheet until there is an empty cell
$iRow = 1
Do
    _ArrayAdd($aArray, _ExcelReadCell($oExcel, $iRow)); Default column is 1
    $aArray[0] += 1 ; Increase element count
    $iRow += 1  ; Move to next row
Until _ExcelReadCell($oExcel, $iRow) = "" ; Looks for an empty cell to end

; Close Excel file
_ExcelBookClose($oExcel)

Happy to answer questions on the first script - but for obvious reasons not the second!

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

Is there a way the selected items can just remain highlighted and not have to have a button to select?

I'm trying to incorporate it into this script and it should be straightforward - but I still need to keep it in my first gui (unless I can figure out how to redisplay the same gui with more items in it, resized(a bit above me yet!) - haven't put the code in yet as I need to know thwe above answer before I do that

;region Script Settings
;<scriptSettings xmlns="http://tempuri.org/ScriptSettings.xsd">
;  <scriptPackager>
;   <process>autoit3.exe</process>
;   <arguments />
;   <extractdir>%TEMP%</extractdir>
;   <files />
;   <usedefaulticon>true</usedefaulticon>
;   <showinsystray>false</showinsystray>
;   <altcreds>false</altcreds>
;   <efs>true</efs>
;   <ntfs>true</ntfs>
;   <local>false</local>
;   <abortonfail>true</abortonfail>
;   <product />
;   <version>1.0.0.1</version>
;   <versionstring />
;   <comments />
;   <includeinterpreter>false</includeinterpreter>
;   <forcecomregistration>false</forcecomregistration>
;   <consolemode>false</consolemode>
;   <EnableChangelog>false</EnableChangelog>
;   <AutoBackup>false</AutoBackup>
;   <snapinforce>false</snapinforce>
;   <snapinshowprogress>false</snapinshowprogress>
;   <snapinautoadd>0</snapinautoadd>
;   <snapinpermanentpath />
;  </ScriptPackager>
;</ScriptSettings>
;endregion

#include <ComboConstants.au3>
#include <Excel.au3>
#include <GuiConstantsEx.au3>
#include <WinAPI.au3>
#include <WindowsConstants.au3>
#include <StaticConstants.au3>
#include <GDIPlus.au3>
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>


Local $widthCell, $msg, $iOldOpt

Dim $Display1 = ""
Dim $sPathAUT = 'C:\Data\AUT.xls'
Dim $sPathUSERS = 'C:\Data\USERS.xls'
Dim $sPathENVS = 'C:\Data\ENVS.xls'
Dim $oExcel1 = _ExcelBookOpen($sPathAUT, 0)
Dim $oExcel2 = _ExcelBookOpen($sPathUSERS, 0)
Dim $oExcel3 = _ExcelBookOpen($sPathENVS, 0)
Dim $aArrayAUT = _ExcelReadSheetToArray($oExcel1)
Dim $aArrayUSER = _ExcelReadSheetToArray($oExcel2)
Dim $aArrayENVS = _ExcelReadSheetToArray($oExcel3)
_ExcelBookClose($oExcel1, 0)

_ExcelBookClose($oExcel3, 0)
Dim $cellcount = 0
Dim $sCellValue = ''
For $i = 1 to 256
    $sCellValue = _ExcelReadCell($oExcel2, $i, 1)
    If $sCellValue = '' Then
    ;MsgBox(0x40, 'Cell count is ', $i)
        $cellcount = $i
        $i = 256
    EndIf
Next
$cellcount = $cellcount - 1 

Dim $sStr = ''
For $i = 1 To $aArrayAUT[0][0]
    For $j = 1 To $aArrayAUT[0][1]
        If $aArrayAUT[$i][$j] <> "" Then $sStr &= $aArrayAUT[$i][$j] & '|'
    Next
Next
$sStr = StringTrimRight($sStr, 1)
Dim $sStr2 = ''
For $i = 1 to $cellcount
    $sStr2 &= _ExcelReadCell($oExcel2, $i, 1) & '|'
Next
_ExcelBookClose($oExcel2, 0)
;Dim $sStr2 = ''
;For $i = 1 To $aArrayUSER[0][0]
;   For $j = 1 To $aArrayUSER[0][1]
;       If $aArrayUSER[$i][$j] <> "" Then $sStr2 &= $aArrayUSER[$i][$j] & '|'
;   Next
;Next
$sStr2 = StringTrimRight($sStr2, 1)
Dim $sStr3 = ''
For $i = 1 To $aArrayENVS[0][0]
    For $j = 1 To $aArrayENVS[0][1]
        If $aArrayENVS[$i][$j] <> "" Then $sStr3 &= $aArrayENVS[$i][$j] & '|'
    Next
Next
$sStr3 = StringTrimRight($sStr3, 1)

#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Rundata Default Selection", 633, 447, 289, 213)
$Group1 = GUICtrlCreateGroup("User Profile Selection", 8, 0, 585, 105)
GUICtrlSetFont(-1, 10, 400, 0, "Verdana")
GUICtrlCreateGroup("1", -99, -99, 1, 1)
GUISetBkColor(0xA6CAF0)
;$Label1 = GUICtrlCreateLabel("   Please Select ", 16, 18, 216, 18)
;GUICtrlSetFont(-1, 9, 800, 0, "Verdana")
;GUICtrlSetColor(-1, 0x000080)
$Label1 = GUICtrlCreateLabel("Application to test", 16, 36, 216, 18)
GUICtrlSetFont(-1, 9, 800, 0, "Verdana")
GUICtrlSetColor(-1, 0x000080)
$AUT = GUICtrlCreateCombo("", 32, 56, 75, 25)
GUICtrlSetFont(-1, 8, 400, 0, "Verdana")
GUICtrlSetData($AUT, $sStr )

$Label2 = GUICtrlCreateLabel("Please Select User", 158, 36, 128, 18)
GUICtrlSetFont(-1, 9, 800, 0, "Verdana")
GUICtrlSetColor(-1, 0x000080)
$USER = GUICtrlCreateCombo("", 158, 56, 115, 25)
GUICtrlSetFont(-1, 8, 400, 0, "Verdana")
GUICtrlSetData($USER, $sStr2 )

$Label3 = GUICtrlCreateLabel("Please Select Environment", 295, 24, 128, 36)
GUICtrlSetFont(-1, 9, 800, 0, "Verdana")
GUICtrlSetColor(-1, 0x000080)
$ENVS = GUICtrlCreateCombo("", 295, 56, 115, 25)
GUICtrlSetFont(-1, 8, 400, 0, "Verdana")
GUICtrlSetData($ENVS, $sStr3 )
$Checkbox1 = GUICtrlCreateCheckbox("Online?", 415, 56, 97, 17)
GUICtrlSetFont(-1, 8, 400, 0, "Verdana")
$OK = GUICtrlCreateButton("OK", 32, 200, 75, 25, 0)
GUISetState()
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

        Case $Label1
        Case $AUT
            $Display = GUICtrlRead($AUT)
        ;MsgBox(0x40, 'Combo Box AUT ', $Display)       
        Case $USER
            $Display1 = GUICtrlRead($USER)
        ;MsgBox(0x40, 'Combo Box User ', $Display1)
        Case $ENVS 
            $Display2 = GUICtrlRead($ENVS)
        ;MsgBox(0x40, 'Combo Box User ', $Display1)
        ;MsgBox(0x40, 'Combo Box Items', GUICtrlRead($ENVS))
        ;MsgBox(0x40, 'Combo Box ENVS ', $Display2)
        Case $Checkbox1
            $Checkboxin1 = GUICtrlRead($Checkbox1)
            if $Checkboxin1 = 1 Then
                MsgBox(0x40, 'Check Box is on', $Checkboxin1 ,10)
                MsgBox(0x40, 'please make sure browsers are turned off', $Checkboxin1 ,10)
            endif
        Case $OK
        ;MsgBox(0x40, 'Pressed Button - can I create a new gui?', "I create a new gui?")
        ;MsgBox(0x40, 'These are values retrieved', "AUT " & $Display & " USER " & $Display1 & " ENVS " & $Display2)
            #Region ### START Koda GUI section ### Form=E:\Autoit-workarea\DET1.kxf
        ;GUICtrlSetState(-1, $GUI_DISABLE + $GUI_HIDE )
            $Form2 = GUICreate("Run Defaults", 634, 448, 289, 213)
            GUISetBkColor(0xA6CAF0)
            $Group1 = GUICtrlCreateGroup("Global Default Details", 32, 8, 489, 57)
            GUICtrlSetFont(-1, 10, 400, 0, "Verdana")
            $Fullname = GUICtrlCreateLabel("Full Name", 48, 32, 60, 17)
            
            $Input1 = GUICtrlCreateInput($Display1, 112, 32, 121, 21)
            $oExcel2 = _ExcelBookOpen($sPathUSERS, 0)
            $aArrayUSER = _ExcelReadSheetToArray($oExcel2)
            Dim $sDetIdValue = ''
            For $i = 1 to 256
            ;MsgBox(0x40, 'Read this DETID',_ExcelReadCell($oExcel2, $i, 1) &  _ExcelReadCell($oExcel2, $i, 2))
            ;MsgBox(0x40, 'This is Display1 ', $Display1 )
                If _ExcelReadCell($oExcel2, $i, 1) = $Display1 Then
                ;MsgBox(0x40, 'This is what was read ', _ExcelReadCell($oExcel2, $i, 1) )
                ;MsgBox(0x40, 'This is Display1 ', $Display1 )
                    $sDetIdValue = _ExcelReadCell($oExcel2, $i, 2)
                EndIf
                If _ExcelReadCell($oExcel2, $i, 1) = '' Then
                ;MsgBox(0x40, 'Cell count is ', $i)
                    $cellcount = $i
                    $i = 256
                EndIf
            Next
            $cellcount = $cellcount - 1 
            _ExcelBookClose($oExcel2, 0)
            
            $hForm1 = GUICtrlGetHandle($Form1)
        ;GUIDelete();   
            $Label1 = GUICtrlCreateLabel("DET User Id", 248, 32, 73, 17)
            $Input2 = GUICtrlCreateInput($sDetIdValue, 344, 32, 121, 21)
            GUICtrlCreateGroup("", -99, -99, 1, 1)
            $Group2 = GUICtrlCreateGroup("Course Offering Creation", 32, 80, 593, 113)
            GUICtrlSetFont(-1, 10, 400, 0, "Verdana")
            $Year = GUICtrlCreateLabel("Year", 40, 104, 30, 17)
            $Combo1 = GUICtrlCreateCombo("Year", 80, 104, 33, 25)
            $Semesterlabel = GUICtrlCreateLabel("Semester", 120, 104, 59, 17)
            $Semester = GUICtrlCreateCombo("Semester", 192, 104, 73, 25)
            $Label2 = GUICtrlCreateLabel("Course No", 272, 104, 64, 17)
            $Course = GUICtrlCreateCombo("Course No", 344, 104, 65, 25)
            $Label3 = GUICtrlCreateLabel("Location No", 40, 144, 70, 17)
            $Location = GUICtrlCreateCombo("Location No\", 120, 144, 89, 25)
            $Label4 = GUICtrlCreateLabel("Offer Type", 232, 144, 65, 17)
            $Combo2 = GUICtrlCreateCombo("Offer Type", 304, 144, 65, 25)
            $Label5 = GUICtrlCreateLabel("Offer Code", 392, 144, 67, 17)
            $Offer = GUICtrlCreateInput("Offer Code", 480, 144, 121, 21)
            GUICtrlCreateGroup("", -99, -99, 1, 1)
            $OK2 = GUICtrlCreateButton("OK", 32, 200, 75, 25, 0)
            GUISetState(@SW_SHOW)
            While 1
                $nMsg = GUIGetMsg()
            Switch $nMsg
                Case $GUI_EVENT_CLOSE
                    Exit

                Case $OK2
                    MsgBox(0x40, 'Pressed Ok2', "I can now process the input params?")
                    Exit            
    EndSwitch
WEnd
#EndRegion ### END Koda GUI section ###

    EndSwitch
WEnd
Func _Update_ListBox()
    
    _GUICtrlListBox_BeginUpdate($hListBox)
    _GUICtrlListBox_ResetContent($hListBox)
    _GUICtrlListBox_InitStorage($hListBox, 100, 4096)
;_GUICtrlListBox_AddString ($hListBox, "")
    For $i = 1 To $aArray[0]
        _GUICtrlListBox_AddString ($hListBox, $aArray[$i]) 
    Next
    _GUICtrlListBox_EndUpdate($hListBox)

EndFunc

joeloyzaga,

This is a commented script using a multi-select ListBox. Click on a list item to select it - holding control permits multiple selections. The selected items are shown in the SciTE console:

#include <GUIConstantsEx.au3>
#Include <GuiListBox.au3>

; Create array - you would do this using the Excel UDFs
Global $aArray[6]

For $i = 1 to 5
    $aArray[$i] = "Something from Excel " & $i - 1
Next
$aArray[0] = 5

; Create a GUI
$hGUI = GUICreate("MultiSelect ListBox", 300, 250)

$hListBox = _GUICtrlListBox_Create ($hGUI, "", 10, 10, 280, 180, $LBS_EXTENDEDSEL)
$hButton_Select = GUICtrlCreateButton("Select", 30, 210, 80, 30)
$hButton_Clear  = GUICtrlCreateButton("Clear", 190, 210, 80, 30)

GUISetState()

; Load ListBox with the array contents
_Update_ListBox()

While 1

; Poll the GUI
    Switch GUIGetMsg()
; Exit
        Case $GUI_EVENT_CLOSE
            Exit
; Select button pressed
        Case $hButton_Select
            $aSelected = _GUICtrlListBox_GetSelItems($hListBox)
    ; Write selected items to console
            For $i = 1 To $aSelected[0]
                ConsoleWrite("Item " & $aSelected[$i] & " selected" & @CRLF)
            Next
            ConsoleWrite(@CRLF)
    ; Use the next case code to clear and reload the ListBox
            ContinueCase
; Clear button pressed
        Case $hButton_Clear
    ; Clear the items to remove selection status
            _GUICtrlListBox_ResetContent($hListBox)
    ; Reload ListBox
            _Update_ListBox()
            
    EndSwitch
    
; Set item to Selected when given focus by a mouse click - if not already done
    $iIndex = _GUICtrlListBox_GetCaretIndex($hListBox)
    If _GUICtrlListBox_GetSel($hListBox, $iIndex) = False Then _GUICtrlListBox_SetSel($hListBox, $iIndex)

WEnd

Func _Update_ListBox()
    
    _GUICtrlListBox_BeginUpdate($hListBox)
    _GUICtrlListBox_ResetContent($hListBox)
    _GUICtrlListBox_InitStorage($hListBox, 100, 4096)
;_GUICtrlListBox_AddString ($hListBox, "")
    For $i = 1 To $aArray[0]
        _GUICtrlListBox_AddString ($hListBox, $aArray[$i]) 
    Next
    _GUICtrlListBox_EndUpdate($hListBox)

EndFunc

I do not use the Excel UDF (because I do not have Excel!), but from the Help file this looks as if it should work:

#Include <Excel.au3>
#include <Array.au3>

; Open an Excel file - set to not visible and read-only
$oExcel = _ExcelBookOpen($sFilePath, 0, True)

; Move to correct sheet
_ExcelSheetActivate($oExcel, $vSheet)

; Read in cells
; Initialise an array
Global $aArray[1]
; Work down sheet until there is an empty cell
$iRow = 1
Do
    _ArrayAdd($aArray, _ExcelReadCell($oExcel, $iRow)); Default column is 1
    $aArray[0] += 1; Increase element count
    $iRow += 1 ; Move to next row
Until _ExcelReadCell($oExcel, $iRow) = ""; Looks for an empty cell to end

; Close Excel file
_ExcelBookClose($oExcel)

Happy to answer questions on the first script - but for obvious reasons not the second!

M23

Share this post


Link to post
Share on other sites

joeloyzaga

Is there a way the selected items can just remain highlighted

If you do not want the items to be deselected unless you press "Clear", just delete the ContinueCase line.

and not have to have a button to select?

How are you going to read the selected items? You need to call _GUICtrlListBox_GetSelItems at some point to get the array of selected items. You could put it in a loop which would continually update the array - but then you would need an event to read the array when required, which amounts to the same thing as creating the array when needed. Could you be a bit more specific?

M23

P.S. Please use the "Add Reply" button rather than the "Reply" button. It is only 1 cm lower on the page and that way you do not repeat the content of the previous post. It makes reading the thread so much easier! :-)


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

I'll reply tomorrow - late here sat night

Share this post


Link to post
Share on other sites

Ok and thanks in advance

I want to insert your example/multi select listbox AS IS into my code - after the checkbox. The code is below and then I want to display the selections in the subsequent resulting gui (the selections should be displayed appended to each other if possible anywhere coz I'll fix up the positioning later) Here's my code

;region Script Settings
;<scriptSettings xmlns="http://tempuri.org/ScriptSettings.xsd">
;  <scriptPackager>
;   <process>autoit3.exe</process>
;   <arguments />
;   <extractdir>%TEMP%</extractdir>
;   <files />
;   <usedefaulticon>true</usedefaulticon>
;   <showinsystray>false</showinsystray>
;   <altcreds>false</altcreds>
;   <efs>true</efs>
;   <ntfs>true</ntfs>
;   <local>false</local>
;   <abortonfail>true</abortonfail>
;   <product />
;   <version>1.0.0.1</version>
;   <versionstring />
;   <comments />
;   <includeinterpreter>false</includeinterpreter>
;   <forcecomregistration>false</forcecomregistration>
;   <consolemode>false</consolemode>
;   <EnableChangelog>false</EnableChangelog>
;   <AutoBackup>false</AutoBackup>
;   <snapinforce>false</snapinforce>
;   <snapinshowprogress>false</snapinshowprogress>
;   <snapinautoadd>0</snapinautoadd>
;   <snapinpermanentpath />
;  </ScriptPackager>
;</ScriptSettings>
;endregion

#include <ComboConstants.au3>
#include <Excel.au3>
#include <GuiConstantsEx.au3>
#include <WinAPI.au3>
#include <WindowsConstants.au3>
#include <StaticConstants.au3>
#include <GDIPlus.au3>
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>

#Include <GuiListBox.au3>

Local $widthCell, $msg, $iOldOpt

Dim $Display1 = ""
Dim $sPathAUT = 'C:\Data\AUT.xls'
Dim $sPathUSERS = 'C:\Data\USERS.xls'
Dim $sPathENVS = 'C:\Data\ENVS.xls'
Dim $oExcel1 = _ExcelBookOpen($sPathAUT, 0)
Dim $oExcel2 = _ExcelBookOpen($sPathUSERS, 0)
Dim $oExcel3 = _ExcelBookOpen($sPathENVS, 0)
Dim $aArrayAUT = _ExcelReadSheetToArray($oExcel1)
Dim $aArrayUSER = _ExcelReadSheetToArray($oExcel2)
Dim $aArrayENVS = _ExcelReadSheetToArray($oExcel3)
_ExcelBookClose($oExcel1, 0)

_ExcelBookClose($oExcel3, 0)
Dim $cellcount = 0
Dim $sCellValue = ''
For $i = 1 to 256
    $sCellValue = _ExcelReadCell($oExcel2, $i, 1)
    If $sCellValue = '' Then
    ;MsgBox(0x40, 'Cell count is ', $i)
        $cellcount = $i
        $i = 256
    EndIf
Next
$cellcount = $cellcount - 1 

Dim $sStr = ''
For $i = 1 To $aArrayAUT[0][0]
    For $j = 1 To $aArrayAUT[0][1]
        If $aArrayAUT[$i][$j] <> "" Then $sStr &= $aArrayAUT[$i][$j] & '|'
    Next
Next
$sStr = StringTrimRight($sStr, 1)
Dim $sStr2 = ''
For $i = 1 to $cellcount
    $sStr2 &= _ExcelReadCell($oExcel2, $i, 1) & '|'
Next
_ExcelBookClose($oExcel2, 0)
;Dim $sStr2 = ''
;For $i = 1 To $aArrayUSER[0][0]
;   For $j = 1 To $aArrayUSER[0][1]
;       If $aArrayUSER[$i][$j] <> "" Then $sStr2 &= $aArrayUSER[$i][$j] & '|'
;   Next
;Next
$sStr2 = StringTrimRight($sStr2, 1)
Dim $sStr3 = ''
For $i = 1 To $aArrayENVS[0][0]
    For $j = 1 To $aArrayENVS[0][1]
        If $aArrayENVS[$i][$j] <> "" Then $sStr3 &= $aArrayENVS[$i][$j] & '|'
    Next
Next
$sStr3 = StringTrimRight($sStr3, 1)
Global $aArray[6]

For $i = 1 to 5
    $aArray[$i] = "Something from Excel " & $i - 1
Next
$aArray[0] = 5
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Rundata Default Selection", 633, 447, 289, 213)
$Group1 = GUICtrlCreateGroup("User Profile Selection", 8, 0, 585, 105)
GUICtrlSetFont(-1, 10, 400, 0, "Verdana")
GUICtrlCreateGroup("1", -99, -99, 1, 1)
GUISetBkColor(0xA6CAF0)
;$Label1 = GUICtrlCreateLabel("   Please Select ", 16, 18, 216, 18)
;GUICtrlSetFont(-1, 9, 800, 0, "Verdana")
;GUICtrlSetColor(-1, 0x000080)
$Label1 = GUICtrlCreateLabel("Application to test", 16, 36, 216, 18)
GUICtrlSetFont(-1, 9, 800, 0, "Verdana")
GUICtrlSetColor(-1, 0x000080)
$AUT = GUICtrlCreateCombo("", 32, 56, 75, 25)
GUICtrlSetFont(-1, 8, 400, 0, "Verdana")
GUICtrlSetData($AUT, $sStr )

$Label2 = GUICtrlCreateLabel("Please Select User", 158, 36, 128, 18)
GUICtrlSetFont(-1, 9, 800, 0, "Verdana")
GUICtrlSetColor(-1, 0x000080)
$USER = GUICtrlCreateCombo("", 158, 56, 115, 25)
GUICtrlSetFont(-1, 8, 400, 0, "Verdana")
GUICtrlSetData($USER, $sStr2 )

$Label3 = GUICtrlCreateLabel("Please Select Environment", 295, 24, 128, 36)
GUICtrlSetFont(-1, 9, 800, 0, "Verdana")
GUICtrlSetColor(-1, 0x000080)
$ENVS = GUICtrlCreateCombo("", 295, 56, 115, 25)
GUICtrlSetFont(-1, 9, 400, 0, "Verdana")
GUICtrlSetData($ENVS, $sStr3 )
$Checkbox1 = GUICtrlCreateCheckbox("Online?", 475, 56, 97, 17)
GUICtrlSetFont(-1, 9, 800, 0, "Verdana")
$OK = GUICtrlCreateButton("OK", 32, 200, 75, 25, 0)

GUISetState()
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

        Case $Label1
        Case $AUT
            $DisplayAUT = GUICtrlRead($AUT)
        ;MsgBox(0x40, 'Combo Box AUT ', $Display)       
        Case $USER
            $DisplayUSER = GUICtrlRead($USER)
        ;MsgBox(0x40, 'Combo Box User ', $Display1)
        Case $ENVS 
            $DisplayENV = GUICtrlRead($ENVS)
        ;MsgBox(0x40, 'Combo Box User ', $Display1)
        ;MsgBox(0x40, 'Combo Box Items', GUICtrlRead($ENVS))
        ;MsgBox(0x40, 'Combo Box ENVS ', $Display2)
        Case $Checkbox1
            $Checkboxonline = GUICtrlRead($Checkbox1)
            If $Checkboxonline = 1 Then
                MsgBox(0x40, 'Check Box is on', $Checkboxonline ,10)
                MsgBox(0x40, 'please make sure browsers are turned off', $Checkboxonline ,10)

            EndIf
        Case $OK
        ;MsgBox(0x40, 'Pressed Button - can I create a new gui?', "I create a new gui?")
        ;MsgBox(0x40, 'These are values retrieved', "AUT " & $Display & " USER " & $Display1 & " ENVS " & $Display2)
            #Region ### START Koda GUI section ### Form=E:\Autoit-workarea\DET1.kxf
        ;GUICtrlSetState(-1, $GUI_DISABLE + $GUI_HIDE )
            $Form2 = GUICreate("Run Defaults", 634, 448, 289, 213)
            GUISetBkColor(0xA6CAF0)
            $Group1 = GUICtrlCreateGroup("Global Default Details", 32, 8, 489, 57)
            GUICtrlSetFont(-1, 10, 400, 0, "Verdana")
            $Fullname = GUICtrlCreateLabel("Full Name", 48, 32, 60, 17)
            
            $Input1 = GUICtrlCreateInput($DisplayUSER, 112, 32, 121, 21)
            $oExcel2 = _ExcelBookOpen($sPathUSERS, 0)
            $aArrayUSER = _ExcelReadSheetToArray($oExcel2)
            Dim $sDetIdValue = ''
            For $i = 1 to 256
            ;MsgBox(0x40, 'Read this DETID',_ExcelReadCell($oExcel2, $i, 1) &  _ExcelReadCell($oExcel2, $i, 2))
            ;MsgBox(0x40, 'This is Display1 ', $Display1 )
                If _ExcelReadCell($oExcel2, $i, 1) = $DisplayUSER Then
                ;MsgBox(0x40, 'This is what was read ', _ExcelReadCell($oExcel2, $i, 1) )
                ;MsgBox(0x40, 'This is Display1 ', $Display1 )
                    $sDetIdValue = _ExcelReadCell($oExcel2, $i, 2)
                EndIf
                If _ExcelReadCell($oExcel2, $i, 1) = '' Then
                ;MsgBox(0x40, 'Cell count is ', $i)
                    $cellcount = $i
                    $i = 256
                EndIf
            Next
            $cellcount = $cellcount - 1 
            _ExcelBookClose($oExcel2, 0)
            
            $hForm1 = GUICtrlGetHandle($Form1)
        ;GUIDelete();   
            $Label1 = GUICtrlCreateLabel("DET User Id", 248, 32, 73, 17)
            $Input2 = GUICtrlCreateInput($sDetIdValue, 344, 32, 121, 21)
            GUICtrlCreateGroup("", -99, -99, 1, 1)
            $Group2 = GUICtrlCreateGroup("Course Offering Creation", 32, 80, 593, 113)
            GUICtrlSetFont(-1, 10, 400, 0, "Verdana")
            $Year = GUICtrlCreateLabel("Year", 40, 104, 30, 17)
            $Combo1 = GUICtrlCreateCombo("Year", 80, 104, 33, 25)
            $Semesterlabel = GUICtrlCreateLabel("Semester", 120, 104, 59, 17)
            $Semester = GUICtrlCreateCombo("Semester", 192, 104, 73, 25)
            $Label2 = GUICtrlCreateLabel("Course No", 272, 104, 64, 17)
            $Course = GUICtrlCreateCombo("Course No", 344, 104, 65, 25)
            $Label3 = GUICtrlCreateLabel("Location No", 40, 144, 70, 17)
            $Location = GUICtrlCreateCombo("Location No\", 120, 144, 89, 25)
            $Label4 = GUICtrlCreateLabel("Offer Type", 232, 144, 65, 17)
            $Combo2 = GUICtrlCreateCombo("Offer Type", 304, 144, 65, 25)
            $Label5 = GUICtrlCreateLabel("Offer Code", 392, 144, 67, 17)
            $Offer = GUICtrlCreateInput("Offer Code", 480, 144, 121, 21)
            GUICtrlCreateGroup("", -99, -99, 1, 1)
            $OK2 = GUICtrlCreateButton("OK", 32, 200, 75, 25, 0)
            GUISetState(@SW_SHOW)
            While 1
                $nMsg = GUIGetMsg()
            Switch $nMsg
                Case $GUI_EVENT_CLOSE
                    Exit

                Case $OK2
                    MsgBox(0x40, 'Pressed Ok2', "I can now process the input params?")
                    Exit            
    EndSwitch
WEnd
#EndRegion ### END Koda GUI section ###

    EndSwitch
WEnd
Func _Update_ListBox()
    
    _GUICtrlListBox_BeginUpdate($hListBox)
    _GUICtrlListBox_ResetContent($hListBox)
    _GUICtrlListBox_InitStorage($hListBox, 100, 4096)
;_GUICtrlListBox_AddString ($hListBox, "")
    For $i = 1 To $aArray[0]
        _GUICtrlListBox_AddString ($hListBox, $aArray[$i]) 
    Next
    _GUICtrlListBox_EndUpdate($hListBox)

EndFunc

Share this post


Link to post
Share on other sites

joeloyzaga,

Add the following code:

Your lines 133-135 become:

$Checkbox1 = GUICtrlCreateCheckbox("Online?", 475, 56, 97, 17)
GUICtrlSetFont(-1, 9, 800, 0, "Verdana")

$hListBox = _GUICtrlListBox_Create ($Form1, "", 10, 230, 280, 180, $LBS_EXTENDEDSEL)
_Update_ListBox()

$OK = GUICtrlCreateButton("OK", 32, 200, 75, 25, 0)

Your lines 216-217 become:

GUICtrlCreateGroup("", -99, -99, 1, 1)
            
$aSelected = _GUICtrlListBox_GetSelItems($hListBox)
$sSelected = ""
For $i = 1 To $aSelected[0]
                $sSelected &= $aArray[$aSelected[$i] + 1] & ", " 
Next
GUICtrlCreateLabel($sSelected, 10, 230, 430, 20)
            
$OK2 = GUICtrlCreateButton("OK", 32, 200, 75, 25, 0)

You already have the _Update_Listbox function, so that shoudl be all you need to get on to the next phase.

A word of warning - if the user does not select a value in the $AUT, $USER and $ENVS combos, you will get an error when you try to create your second GUI. This is because the GUICtrlRead statements that set these values are in another Case section which would not have been called - leading to a "Variable not defined" error. I would declare the 3 $DisplayAUT/USER/ENVS variables at the start to avoid this. You might also consider a bit of errorchecking to prevent the user from causing the error - perhaps checking if the 3 combos have variables selected before enabling the OK button.

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

Did as you suggested and got attached error - I sure I goofed somewhere

;region Script Settings
;<scriptSettings xmlns="http://tempuri.org/ScriptSettings.xsd">
;  <scriptPackager>
;   <process>autoit3.exe</process>
;   <arguments />
;   <extractdir>%TEMP%</extractdir>
;   <files />
;   <usedefaulticon>true</usedefaulticon>
;   <showinsystray>false</showinsystray>
;   <altcreds>false</altcreds>
;   <efs>true</efs>
;   <ntfs>true</ntfs>
;   <local>false</local>
;   <abortonfail>true</abortonfail>
;   <product />
;   <version>1.0.0.1</version>
;   <versionstring />
;   <comments />
;   <includeinterpreter>false</includeinterpreter>
;   <forcecomregistration>false</forcecomregistration>
;   <consolemode>false</consolemode>
;   <EnableChangelog>false</EnableChangelog>
;   <AutoBackup>false</AutoBackup>
;   <snapinforce>false</snapinforce>
;   <snapinshowprogress>false</snapinshowprogress>
;   <snapinautoadd>0</snapinautoadd>
;   <snapinpermanentpath />
;  </ScriptPackager>
;</ScriptSettings>
;endregion

#include <ComboConstants.au3>
#include <Excel.au3>
#include <GuiConstantsEx.au3>
#include <WinAPI.au3>
#include <WindowsConstants.au3>
#include <StaticConstants.au3>
#include <GDIPlus.au3>
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#Include <GuiListBox.au3>

Local $widthCell, $msg, $iOldOpt

Dim $Display1 = ""
Dim $sPathAUT = 'C:\Data\AUT.xls'
Dim $sPathUSERS = 'C:\Data\USERS.xls'
Dim $sPathENVS = 'C:\Data\ENVS.xls'
Dim $oExcel1 = _ExcelBookOpen($sPathAUT, 0)
Dim $oExcel2 = _ExcelBookOpen($sPathUSERS, 0)
Dim $oExcel3 = _ExcelBookOpen($sPathENVS, 0)
Dim $aArrayAUT = _ExcelReadSheetToArray($oExcel1)
Dim $aArrayUSER = _ExcelReadSheetToArray($oExcel2)
Dim $aArrayENVS = _ExcelReadSheetToArray($oExcel3)
_ExcelBookClose($oExcel1, 0)

_ExcelBookClose($oExcel3, 0)
Dim $cellcount = 0
Dim $sCellValue = ''
For $i = 1 to 256
    $sCellValue = _ExcelReadCell($oExcel2, $i, 1)
    If $sCellValue = '' Then
    ;MsgBox(0x40, 'Cell count is ', $i)
        $cellcount = $i
        $i = 256
    EndIf
Next
$cellcount = $cellcount - 1 

Dim $sStr = ''
For $i = 1 To $aArrayAUT[0][0]
    For $j = 1 To $aArrayAUT[0][1]
        If $aArrayAUT[$i][$j] <> "" Then $sStr &= $aArrayAUT[$i][$j] & '|'
    Next
Next
$sStr = StringTrimRight($sStr, 1)
Dim $sStr2 = ''
For $i = 1 to $cellcount
    $sStr2 &= _ExcelReadCell($oExcel2, $i, 1) & '|'
Next
_ExcelBookClose($oExcel2, 0)
;Dim $sStr2 = ''
;For $i = 1 To $aArrayUSER[0][0]
;   For $j = 1 To $aArrayUSER[0][1]
;       If $aArrayUSER[$i][$j] <> "" Then $sStr2 &= $aArrayUSER[$i][$j] & '|'
;   Next
;Next
$sStr2 = StringTrimRight($sStr2, 1)
Dim $sStr3 = ''
For $i = 1 To $aArrayENVS[0][0]
    For $j = 1 To $aArrayENVS[0][1]
        If $aArrayENVS[$i][$j] <> "" Then $sStr3 &= $aArrayENVS[$i][$j] & '|'
    Next
Next
$sStr3 = StringTrimRight($sStr3, 1)

#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Rundata Default Selection", 633, 447, 289, 213)
$Group1 = GUICtrlCreateGroup("User Profile Selection", 8, 0, 585, 105)
GUICtrlSetFont(-1, 10, 400, 0, "Verdana")
GUICtrlCreateGroup("1", -99, -99, 1, 1)
GUISetBkColor(0xA6CAF0)
;$Label1 = GUICtrlCreateLabel("   Please Select ", 16, 18, 216, 18)
;GUICtrlSetFont(-1, 9, 800, 0, "Verdana")
;GUICtrlSetColor(-1, 0x000080)
$Label1 = GUICtrlCreateLabel("Application to test", 16, 36, 216, 18)
GUICtrlSetFont(-1, 9, 800, 0, "Verdana")
GUICtrlSetColor(-1, 0x000080)
$AUT = GUICtrlCreateCombo("", 32, 56, 75, 25)
GUICtrlSetFont(-1, 8, 400, 0, "Verdana")
GUICtrlSetData($AUT, $sStr )

$Label2 = GUICtrlCreateLabel("Please Select User", 158, 36, 128, 18)
GUICtrlSetFont(-1, 9, 800, 0, "Verdana")
GUICtrlSetColor(-1, 0x000080)
$USER = GUICtrlCreateCombo("", 158, 56, 115, 25)
GUICtrlSetFont(-1, 8, 400, 0, "Verdana")
GUICtrlSetData($USER, $sStr2 )

$Label3 = GUICtrlCreateLabel("Please Select Environment", 295, 24, 128, 36)
GUICtrlSetFont(-1, 9, 800, 0, "Verdana")
GUICtrlSetColor(-1, 0x000080)
$ENVS = GUICtrlCreateCombo("", 295, 56, 115, 25)
GUICtrlSetFont(-1, 8, 400, 0, "Verdana")
GUICtrlSetData($ENVS, $sStr3 )
$Checkbox1 = GUICtrlCreateCheckbox("Online?", 475, 56, 97, 17)
GUICtrlSetFont(-1, 9, 800, 0, "Verdana")

$hListBox = _GUICtrlListBox_Create ($Form1, "", 10, 230, 280, 180, $LBS_EXTENDEDSEL)
_Update_ListBox()

$OK = GUICtrlCreateButton("OK", 32, 200, 75, 25, 0)
GUISetState()
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

        Case $Label1
        Case $AUT
            $Display = GUICtrlRead($AUT)
        ;MsgBox(0x40, 'Combo Box AUT ', $Display)       
        Case $USER
            $Display1 = GUICtrlRead($USER)
        ;MsgBox(0x40, 'Combo Box User ', $Display1)
        Case $ENVS 
            $Display2 = GUICtrlRead($ENVS)
        ;MsgBox(0x40, 'Combo Box User ', $Display1)
        ;MsgBox(0x40, 'Combo Box Items', GUICtrlRead($ENVS))
        ;MsgBox(0x40, 'Combo Box ENVS ', $Display2)
        Case $Checkbox1
            $Checkboxin1 = GUICtrlRead($Checkbox1)
            if $Checkboxin1 = 1 Then
                MsgBox(0x40, 'Check Box is on', $Checkboxin1 ,10)
                MsgBox(0x40, 'please make sure browsers are turned off', $Checkboxin1 ,10)
            endif
        Case $OK
        ;MsgBox(0x40, 'Pressed Button - can I create a new gui?', "I create a new gui?")
        ;MsgBox(0x40, 'These are values retrieved', "AUT " & $Display & " USER " & $Display1 & " ENVS " & $Display2)
            #Region ### START Koda GUI section ### Form=E:\Autoit-workarea\DET1.kxf
        ;GUICtrlSetState(-1, $GUI_DISABLE + $GUI_HIDE )
            $Form2 = GUICreate("Run Defaults", 634, 448, 289, 213)
            GUISetBkColor(0xA6CAF0)
            $Group1 = GUICtrlCreateGroup("Global Default Details", 32, 8, 489, 57)
            GUICtrlSetFont(-1, 10, 400, 0, "Verdana")
            $Fullname = GUICtrlCreateLabel("Full Name", 48, 32, 60, 17)
            
            $Input1 = GUICtrlCreateInput($Display1, 112, 32, 121, 21)
            $oExcel2 = _ExcelBookOpen($sPathUSERS, 0)
            $aArrayUSER = _ExcelReadSheetToArray($oExcel2)
            Dim $sDetIdValue = ''
            For $i = 1 to 256
            ;MsgBox(0x40, 'Read this DETID',_ExcelReadCell($oExcel2, $i, 1) &  _ExcelReadCell($oExcel2, $i, 2))
            ;MsgBox(0x40, 'This is Display1 ', $Display1 )
                If _ExcelReadCell($oExcel2, $i, 1) = $Display1 Then
                ;MsgBox(0x40, 'This is what was read ', _ExcelReadCell($oExcel2, $i, 1) )
                ;MsgBox(0x40, 'This is Display1 ', $Display1 )
                    $sDetIdValue = _ExcelReadCell($oExcel2, $i, 2)
                EndIf
                If _ExcelReadCell($oExcel2, $i, 1) = '' Then
                ;MsgBox(0x40, 'Cell count is ', $i)
                    $cellcount = $i
                    $i = 256
                EndIf
            Next
            $cellcount = $cellcount - 1 
            _ExcelBookClose($oExcel2, 0)
            
            $hForm1 = GUICtrlGetHandle($Form1)
        ;GUIDelete();   
            $Label1 = GUICtrlCreateLabel("DET User Id", 248, 32, 73, 17)
            $Input2 = GUICtrlCreateInput($sDetIdValue, 344, 32, 121, 21)
            GUICtrlCreateGroup("", -99, -99, 1, 1)
            $Group2 = GUICtrlCreateGroup("Course Offering Creation", 32, 80, 593, 113)
            GUICtrlSetFont(-1, 10, 400, 0, "Verdana")
            $Year = GUICtrlCreateLabel("Year", 40, 104, 30, 17)
            $Combo1 = GUICtrlCreateCombo("Year", 80, 104, 33, 25)
            $Semesterlabel = GUICtrlCreateLabel("Semester", 120, 104, 59, 17)
            $Semester = GUICtrlCreateCombo("Semester", 192, 104, 73, 25)
            $Label2 = GUICtrlCreateLabel("Course No", 272, 104, 64, 17)
            $Course = GUICtrlCreateCombo("Course No", 344, 104, 65, 25)
            $Label3 = GUICtrlCreateLabel("Location No", 40, 144, 70, 17)
            $Location = GUICtrlCreateCombo("Location No\", 120, 144, 89, 25)
            $Label4 = GUICtrlCreateLabel("Offer Type", 232, 144, 65, 17)
            $Combo2 = GUICtrlCreateCombo("Offer Type", 304, 144, 65, 25)
            $Label5 = GUICtrlCreateLabel("Offer Code", 392, 144, 67, 17)
            $Offer = GUICtrlCreateInput("Offer Code", 480, 144, 121, 21)
            GUICtrlCreateGroup("", -99, -99, 1, 1)
            $aArray = ""
            $aSelected = _GUICtrlListBox_GetSelItems($hListBox)
            $sSelected = ""
            For $i = 1 To $aSelected[0]
                $sSelected &= $aArray[$aSelected[$i] + 1] & ", " 
            Next
            GUICtrlCreateLabel($sSelected, 10, 230, 430, 20)
            
            $OK2 = GUICtrlCreateButton("OK", 32, 200, 75, 25, 0)
            GUISetState(@SW_SHOW)
            While 1
                $nMsg = GUIGetMsg()
            Switch $nMsg
                Case $GUI_EVENT_CLOSE
                    Exit

                Case $OK2
                    MsgBox(0x40, 'Pressed Ok2', "I can now process the input params?")
                    Exit            
    EndSwitch
WEnd
#EndRegion ### END Koda GUI section ###

    EndSwitch
WEnd
Func _Update_ListBox()
    
    _GUICtrlListBox_BeginUpdate($hListBox)
    _GUICtrlListBox_ResetContent($hListBox)
    _GUICtrlListBox_InitStorage($hListBox, 100, 4096)
;_GUICtrlListBox_AddString ($hListBox, "")
    For $i = 1 To $aArray[0]
        _GUICtrlListBox_AddString ($hListBox, $aArray[$i]) 
    Next
    _GUICtrlListBox_EndUpdate($hListBox)

EndFunc

joeloyzaga,

Add the following code:

Your lines 133-135 become:

$Checkbox1 = GUICtrlCreateCheckbox("Online?", 475, 56, 97, 17)
GUICtrlSetFont(-1, 9, 800, 0, "Verdana")

$hListBox = _GUICtrlListBox_Create ($Form1, "", 10, 230, 280, 180, $LBS_EXTENDEDSEL)
_Update_ListBox()

$OK = GUICtrlCreateButton("OK", 32, 200, 75, 25, 0)

Your lines 216-217 become:

GUICtrlCreateGroup("", -99, -99, 1, 1)
            
$aSelected = _GUICtrlListBox_GetSelItems($hListBox)
$sSelected = ""
For $i = 1 To $aSelected[0]
                $sSelected &= $aArray[$aSelected[$i] + 1] & ", " 
Next
GUICtrlCreateLabel($sSelected, 10, 230, 430, 20)
            
$OK2 = GUICtrlCreateButton("OK", 32, 200, 75, 25, 0)

You already have the _Update_Listbox function, so that shoudl be all you need to get on to the next phase.

A word of warning - if the user does not select a value in the $AUT, $USER and $ENVS combos, you will get an error when you try to create your second GUI. This is because the GUICtrlRead statements that set these values are in another Case section which would not have been called - leading to a "Variable not defined" error. I would declare the 3 $DisplayAUT/USER/ENVS variables at the start to avoid this. You might also consider a bit of errorchecking to prevent the user from causing the error - perhaps checking if the 3 combos have variables selected before enabling the OK button.

M23

Share this post


Link to post
Share on other sites

joeloyzaga,

The error message gives you the answer - $aArray is not declared - and this happens on Line 244. Line 244 is in the _Update_ListBox() function - so we need to declare $aArray as a Global variable so it is available to the function - or we could pass it as a parameter. Easiest is to declare it - so add:

Global $aArray[1]

at the top of yor script where you declare your other variables.

Seriously, if you could not work that out yourself, you need to spend a bit of time learning some of the basics of Autoit scripting. It will serve you well in the long run. A good read of the Help file (at least the first few sections - Using AutoIt, Tutorials and the first couple of References) will help you enormously. You should also perhaps look at the excellent tutorials that you will find here and here. I know that sounds a bit condescending, but it really would be worth your while, believe me.

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

joeloyzaga,

The error message gives you the answer - $aArray is not declared - and this happens on Line 244. Line 244 is in the _Update_ListBox() function - so we need to declare $aArray as a Global variable so it is available to the function - or we could pass it as a parameter. Easiest is to declare it - so add:

Global $aArray[1]

at the top of yor script where you declare your other variables.

Seriously, if you could not work that out yourself, you need to spend a bit of time learning some of the basics of Autoit scripting. It will serve you well in the long run. A good read of the Help file (at least the first few sections - Using AutoIt, Tutorials and the first couple of References) will help you enormously. You should also perhaps look at the excellent tutorials that you will find here and here. I know that sounds a bit condescending, but it really would be worth your while, believe me.

M23

I thought that was what needed to be done but I thought it wouldn't be that obvious coz it wasn't part of the code sent

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
Sign in to follow this  
Followers 0