Jump to content

Recommended Posts

Posted

Hi, 

I just started recently with AutoIT and I am trying to make two dropdownlists where the selectable values of the second dropdownlist will be depending on what is selected on the first one.

For example: 

Dropdown 1                 Dropdown 2                   

xxx                =>             01-15    ("01" , "02" ,"03" , ...)                    
yyy                =>             a - f       ("a" , "b" ,"c" ,"d" ,"e" ,"f" ) 
zzz                =>             "new", "old", "spare"

 

I started with this code that I've found in this Forum:

#include <GUIConstantsEx.au3>

; Here is the array
Global $aArray[6] = ["SORT", "PCM", "UNIF", "KKE", "GMS", "CDY"]

; And here we get the elements into a list
$sList = ""
For $i = 0 To UBound($aArray) - 1
    $sList &= "|" & $aArray[$i]
Next

; Create a GUI
#include <GUIConstantsEx.au3>

$hGUI = GUICreate("DropDown", 500, 500)

; Create the combo
$hCombo = GUICtrlCreateCombo("", 10, 10, 200, 20)
; And fill it
GUICtrlSetData($hCombo, $sList)

GUISetState()

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

 

Any idea how to start on this one...

thanks upfront

 

 

 

Posted

here a small demo with 2 comboboxes:

#Include <GuiComboBox.au3>
#include <GUIConstantsEx.au3>
#include <array.au3>
#include <File.au3>

Const $sCSV = @AppDataDir & "\2cbo.CSV"
Const $sElect = "bitte auswählen"
Dim $a_sCSV, $aSplit, $scboChr = ""
_FileReadToArray($sCSV,$a_sCSV)
Dim $aCSV[$a_sCSV[0]][2]
for $i = 1 to UBound($a_sCSV) - 1
    ConsoleWrite($i & $a_sCSV[$i] & @CRLF)
    $aSplit = StringSplit($a_sCSV[$i],";")
    if not StringInStr($scboChr,$aSplit[1]) Then $scboChr &= $aSplit[1] & "|"
    $aCSV[$i-1][0] = $aSplit[1]
    $aCSV[$i-1][1] = $aSplit[2]
Next
ConsoleWrite($scboChr & @CRLF)

$hGui = GUICreate("2 Comboboxen aus 1er CSV ", 250, 120, 302, 218)
$hcboChr = GUICtrlCreateCombo($sElect, 8, 8, 200, 25)
GUICtrlSetData(-1,$scboChr)
$hcboChrNr  = GUICtrlCreateCombo("",8,35,200,25)
$hbtnExit = GUICtrlCreateButton("Be&enden", 8, 65)

GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE, $hbtnExit
            Exit
        Case $hcboChr
            $sVal = GUICtrlRead($hcboChr)
            if $sVal <> $sElect Then
                $aSplit = _ArrayFindAll($aCSV,$sVal,0,0,True,True,0)
                GUICtrlSetData($hcboChrNr,"")
                $scboChr = ""
                for $i = 0 to UBound($aSplit) - 1
                    $scboChr &= $aCSV[$aSplit[$i]][1] & "|"
                Next
                ConsoleWrite($scboChr & @CRLF)
                GUICtrlSetData($hcboChrNr,$scboChr)
                _GUICtrlComboBox_SetCurSel($hcboChrNr, 0)
            EndIf
    EndSwitch
WEnd

And here is the csv:

Auto;Felgen
Werkzeug;BitSätze
Werkzeug;Schraubenschlüssel
Auto;Reifen
Zubehör;Enteiserspray

which must be in @AppDataDir.

Posted

Hi , 

Thanks a lot ! Do you have any idea how I could the values not in csv but xml format ?

and in stead of typing full xxx;01 / xxx;02 / xxx;03 /... that I can say range for xxx is from 01 to 05 for example

Posted

Joep86,

Please post an example of your XML file.

  On 2/5/2016 at 4:01 PM, Joep86 said:

and in stead of typing full xxx;01 / xxx;02 / xxx;03 /...

Expand  

Typing it where, for what?

kylomas

Forum Rules         Procedure for posting code

"I like pigs.  Dogs look up to us.  Cats look down on us.  Pigs treat us as equals."

- Sir Winston Churchill

Posted

Hi , 

I would like to read out parameters for a dropdown list from a xml file ? 

in example above it's done through a csv file , how is it possible to do this then with xml ?

let say I have a parameter like this in the xml file :

<ScanP_ProcessNameKill>


-<Input>

<string>SC{0:n8}.{1:n}.</string>

</Input>

<OutPut>{0}.{1:000}</OutPut>

</ScanP_ProcessNameKill>>>

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
×
×
  • Create New...