Lempke Posted November 29, 2006 Share Posted November 29, 2006 (edited) How can I link two combo boxes together in a GUI? When I select a value in the first combo a want second combo box to display a list that connected to that value This is a part of the script I have for now: $Combo_Main = GuiCtrlCreateCombo("", 10, 60, 130, 21) GuiCtrlSetData($Combo_Main, "Concern|Division|Partners") While 1 $Combo_Main = GUICtrlRead($Combo_Main) Select Case $Combo_Main = "Concern" $Combo_sub = GuiCtrlCreateCombo("", 10, 90, 130, 21) GuiCtrlSetData($Combo_sub, "Item1|Item2|Item3|Item4|Item5") Case $Combo_Main = "Division" $Combo_sub = GuiCtrlCreateCombo("", 10, 90, 130, 21) GuiCtrlSetData($Combo_sub, "Item1|Item2|Item3|Item4") Case $Combo_Main = "Partners" $Combo_sub = GuiCtrlCreateCombo("", 10, 90, 130, 21) GuiCtrlSetData($Combo_sub, "Item1|Item2|Item3") EndSelect WEnd Edited November 29, 2006 by Lempke Link to comment Share on other sites More sharing options...
xcal Posted November 29, 2006 Share Posted November 29, 2006 Try this: expandcollapse popup#include <GUIConstants.au3> Opt('GUIOnEventMode', 1) GUICreate('Dualing Combos', 190, 40) GUISetOnEvent($GUI_EVENT_CLOSE, 'quit') $combo1 = GUICtrlCreateCombo('', 10, 10, 80) GUICtrlSetData(-1, 'Item 1|Item 2|Item 3') GUICtrlSetOnEvent($combo1, 'setgrp') $combo2 = GUICtrlCreateCombo('', 100, 10, 80) GUISetState() While 1 Sleep(50) WEnd Func setgrp() $c_msg = GUICtrlRead($combo1) Switch $c_msg Case 'Item 1' GUICtrlSetData($combo2, '') GUICtrlSetData($combo2, 'Group 1.1|Group 1.2|Group 1.3') Case 'Item 2' GUICtrlSetData($combo2, '') GUICtrlSetData($combo2, 'Group 2.1|Group 2.2|Group 2.3') Case 'Item 3' GUICtrlSetData($combo2, '') GUICtrlSetData($combo2, 'Group 3.1|Group 3.2|Group 3.3') EndSwitch EndFunc Func quit() Exit EndFunc How To Ask Questions The Smart Way Link to comment Share on other sites More sharing options...
Lempke Posted November 29, 2006 Author Share Posted November 29, 2006 THX This is exactly what I had in mind. I hope that I can make it work like this in my script. Link to comment Share on other sites More sharing options...
Lempke Posted November 30, 2006 Author Share Posted November 30, 2006 So far so good. It's is working like I initially wanted it to work. But after using it I have gotten the desire to adjust something. I would be nice if I could get it to loop, but I can't seem to get that working. I want to adjust something when the script has rus the first time, like give another groupname and then run it again bij pressing the create button. I've tried putting in a loop, but I keep getting a error the a variable hasn't been declared. This is my script: expandcollapse popup;********************************** ;******** GUI Create Group ******** ;***** Author: Robert Lemmens ***** ;******* Created: NOV 2006 ******** ;********************************** $Version = "v 1.0" #include <GuiConstants.au3> #include <INet.au3> Opt("TrayIconDebug", 1) Opt("GUIOnEventMode", 1) ;------------------------------------------------- GUI ------------------------------------------------------------ GUICreate("Create Group " & $Version, 320, 170) GuiSetIcon(@SystemDir & "\shell32.dll", 111) GUISetOnEvent($GUI_EVENT_CLOSE, "Quit") ;------------------------------------------------- BUTTONS -------------------------------------------------------- $Btn_Create = GUICtrlCreateButton( "Create", 180, 140, 60, 20) GUICtrlSetState(-1, $GUI_DEFBUTTON) GUICtrlSetOnEvent($Btn_Create, "Batch") $Btn_Exit = GUICtrlCreateButton( "Exit", 250, 140, 60, 20) GUICtrlSetOnEvent($Btn_Exit, "Quit") ;------------------------------------------------- FRAMES --------------------------------------------------------- GUICtrlCreateGroup ("Destination", 10, 10, 300, 50) GUICtrlCreateGroup ("GroupName", 10, 70, 300, 50) ;------------------------------------------------- INPUT FIELD ---------------------------------------------------- $GroupName = GuiCtrlCreateInput("", 20, 90, 280, 20) ;------------------------------------------------- COMBO BOXES ---------------------------------------------------- $Combo1 = GUICtrlCreateCombo("", 20, 30, 80) GUICtrlSetData(-1, "Concern A|Concern B|Concern C|Concern D|Concern E|") GUICtrlSetOnEvent($Combo1, "OU") $Combo2 = GUICtrlCreateCombo("", 110, 30, 190) ;------------------------------------------------- MAIN ----------------------------------------------------------- GUISetState() While 1 Sleep(50) WEnd ;------------------------------------------------- FUNCTIONS ------------------------------------------------------ Func OU() $msg = GUICtrlRead($Combo1) Switch $msg Case "Concern A" GUICtrlSetData($Combo2, "") GUICtrlSetData($Combo2, "Departement A1|Departement A2|Departement A3|Departement A4") Case "Concern B" GUICtrlSetData($Combo2, "") GUICtrlSetData($Combo2, "Departement B1|Departement B2|Departement B3|Departement B4") Case "Concern C" GUICtrlSetData($Combo2, "") GUICtrlSetData($Combo2, "Departement C1|Departement C2|Departement C3|Departement C4") Case "Concern D" GUICtrlSetData($Combo2, "") GUICtrlSetData($Combo2, "Departement D1|Departement D2|Departement D3|Departement D4") Case "Concern E" GUICtrlSetData($Combo2, "") GUICtrlSetData($Combo2, "Departement E1|Departement E2|Departement E3|Departement E4") EndSwitch EndFunc Func Batch() $OU1 = GUICtrlRead($Combo1) $OU2 = GUICtrlRead($Combo2) $Destination = ",ou=Groups,ou=" & $OU2 & ",ou=" & $OU1 & ",dc=domain,dc=local" $GroupName = GUICtrlRead($GroupName) $DR_R = ("DR " & $GroupName & " (R)") $DR_RW = ("DR " & $GroupName & " (RW)") $GO_R = ("GO " & $GroupName & " (R)") $GO_RW = ("GO " & $GroupName & " (RW)") $Command1 = ("dsadd group ""cn=" & $DR_R & $Destination & """ -secgrp yes -scope L") $Command2 = ("dsadd group ""cn=" & $DR_RW & $Destination & """ -secgrp yes -scope L") $Command3 = ("dsadd group ""cn=" & $GO_R & $Destination & """ -secgrp yes -scope G -memberof ""cn="& $DR_R & $Destination & """") $Command4 = ("dsadd group ""cn=" & $GO_RW & $Destination & """ -secgrp yes -scope G -memberof ""cn=" & $DR_RW & $Destination & """" ) $file = FileOpen("C:\Temp\Groups.bat", 2) ; Check if file opened for writing OK If $file = -1 Then MsgBox(0, "Error", "Unable to open file.") Exit EndIf FileWriteLine($file, $Command1) FileWriteLine($file, $Command2) FileWriteLine($file, $Command3) FileWriteLine($file, $Command4) FileClose($file) Run_Batch() EndFunc Func Run_Batch() Run("C:\Temp\Groups.bat", "", @SW_HIDE) TrayTip("Create Group", "Groups have been created", 1, 1) Sleep(1000) Quit() EndFunc Func Quit() Exit EndFunc Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now