LinuxRabbit Posted August 5, 2009 Share Posted August 5, 2009 I am trying to make a nice little RDP tool to help with the multitude of servers that I have to connect to daily. I have two combo boxes in order to separate the different sites that I have to connect to. The only problem is that after I click on the connect button I want the combo box to go back to empty. I can make this happen but then it results in only one server being shown, the one I connected to. Can someone please help me? By the way I know the code is all frankenstein like, This is my first program written with autoit. expandcollapse popup#include <ButtonConstants.au3> #include <ComboConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> Opt("GUIOnEventMode", 1) HotKeySet("{esc}","exitclick") global $comboh, $combol, $dboxh, $dBoxl global $ini = (@ScriptDir & "\server.ini") global $hsrvs = IniReadSection( $ini, "hsrvs") global $lsrvs = IniReadSection( $ini, "lsrvs") global $rdp = ("C:\windows\system32\mstsc.exe /admin /v:") $gui = GUICreate( "LOL", 320, 23, -1, -1, BitOR($WS_BORDER,$WS_Popup), Bitor($WS_EX_APPWINDOW, $WS_EX_TOPMOST)) GUISetBkColor(0x8393a3) GUICtrlCreateLabel ("", 0, 0, 10, 23, "", $GUI_WS_EX_PARENTDRAG) GUICtrlSetBkColor(-1, "0x3e536b") $connect = GUICtrlCreateButton("connect", 195, 0, 50, 23, $WS_GROUP) GUICtrlSetOnEvent(-1, "connectclick") GUICtrlSetBkColor(-1, "0x3e536b") $exit = GUICtrlCreateButton("exit", 248, 0, 40, 23, $WS_GROUP) GUICtrlSetOnEvent(-1, "exitclick") GUICtrlSetBkColor(-1, "0x3e536b") $edit = GUICtrlCreateButton( "edit", 290, 0, 30,23, $WS_GROUP) GUICtrlSetOnEvent(-1, "editclick") GUICtrlSetBkColor(-1, "0x3e536b") GUISetState() $dBoxh = GUICtrlCreateCombo( "", 10, 0, 90, 25) If @error Then MsgBox(4096, "", "Failed to read server name") Else For $i = 1 To $hsrvs[0][0] GUICtrlSetData($dBoxh, $hsrvs[$i][1], "") Next EndIf $dboxl = GUICtrlCreateCombo( "", 100, 0, 90, 25) If @error Then MsgBox(4096, "", "Failed to read server name") Else For $i = 1 To $lsrvs[0][0] GUICtrlSetData($dBoxl, $lsrvs[$i][1], "") Next EndIf while 1 sleep(100) WEnd Func connectclick() $comboh = GuiCtrlRead($dBoxh) $combol = GUICtrlRead($dboxl) IF $comboh Then Run($rdp & $comboh, "") Else Run($rdp & $combol, "") EndIf GUICtrlSetData($dBoxh, "", "") GUICtrlSetData($dBoxl, "", "") GUICtrlSetData($dBoxh, $hsrvs[2][1]) GUICtrlSetData($dBoxl, $lsrvs[2][1]) EndFunc func exitclick() exit EndFunc func editclick() ShellExecute( "server.ini","", @ScriptDir, "open") EndFunc Link to comment Share on other sites More sharing options...
Info Posted August 5, 2009 Share Posted August 5, 2009 after I click on the connect button I want the combo box to go back to empty.GUICtrlSetData($ComboBox,"") Link to comment Share on other sites More sharing options...
LinuxRabbit Posted August 5, 2009 Author Share Posted August 5, 2009 I guess I should have made my intentions clearer. I do not want to erase the data to be selected from the combo box, just the input field. I still want to be able to select from the array. I can always just delete what is in the field, but I would much rather have a way to reset the input box. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted August 5, 2009 Moderators Share Posted August 5, 2009 LinuxRabbit,The function you need is _GUICtrlComboBox_SetEditText from the UDF GuiComboBox.au3. I think this modified version of your code will do what you want:expandcollapse popup#include <ButtonConstants.au3> #include <ComboConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #Include <GuiComboBox.au3> ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< Opt("GUIOnEventMode", 1) HotKeySet("{esc}","exitclick") global $comboh, $combol, $dboxh, $dBoxl global $ini = (@ScriptDir & "\server.ini") ;global $hsrvs = IniReadSection( $ini, "hsrvs") ;global $lsrvs = IniReadSection( $ini, "lsrvs") global $rdp = ("C:\windows\system32\mstsc.exe /admin /v:") $gui = GUICreate( "LOL", 320, 23, -1, -1, BitOR($WS_BORDER,$WS_Popup), Bitor($WS_EX_APPWINDOW, $WS_EX_TOPMOST)) GUISetBkColor(0x8393a3) GUICtrlCreateLabel ("", 0, 0, 10, 23, "", $GUI_WS_EX_PARENTDRAG) GUICtrlSetBkColor(-1, "0x3e536b") $connect = GUICtrlCreateButton("connect", 195, 0, 50, 23, $WS_GROUP) GUICtrlSetOnEvent(-1, "connectclick") GUICtrlSetBkColor(-1, "0x3e536b") $exit = GUICtrlCreateButton("exit", 248, 0, 40, 23, $WS_GROUP) GUICtrlSetOnEvent(-1, "exitclick") GUICtrlSetBkColor(-1, "0x3e536b") $edit = GUICtrlCreateButton( "edit", 290, 0, 30,23, $WS_GROUP) GUICtrlSetOnEvent(-1, "editclick") GUICtrlSetBkColor(-1, "0x3e536b") GUISetState() $dBoxh = GUICtrlCreateCombo( "", 10, 0, 90, 25) If @error Then MsgBox(4096, "", "Failed to read server name") Else ;For $i = 1 To $hsrvs[0][0] GUICtrlSetData($dBoxh, "1|2|3|4|5|6|7", "") ; simulate combo load ;Next EndIf $dboxl = GUICtrlCreateCombo( "", 100, 0, 90, 25) If @error Then MsgBox(4096, "", "Failed to read server name") Else ;For $i = 1 To $lsrvs[0][0] GUICtrlSetData($dBoxl, "A|B|C|D|E|F|G", "") ; simulate combo load ;Next EndIf while 1 sleep(100) WEnd Func connectclick() $comboh = GuiCtrlRead($dBoxh) $combol = GUICtrlRead($dboxl) IF $comboh Then ;Run($rdp & $comboh, "") MsgBox(0, "Run", $comboh) ; simulate Run Else ;Run($rdp & $combol, "") MsgBox(0, "Run", $comboh) ; simulate Run EndIf _GUICtrlComboBox_SetEditText($dBoxh, "") ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< _GUICtrlComboBox_SetEditText($dBoxl, "") ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< EndFunc func exitclick() exit EndFunc func editclick() ShellExecute( "server.ini","", @ScriptDir, "open") EndFuncThe changes are pretty easy to spot. >_< M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
somdcomputerguy Posted August 5, 2009 Share Posted August 5, 2009 Try it this way: create two new functions, like this, Func One For $i = 1 To $hsrvs[0][0] GUICtrlSetData($dBoxh, $hsrvs[$i][1], "") Next EndFunc the second function with the other Else contents Call these two functions, replacing the last four lines of the connectclick funtion. This may or may not (probably not >_<) work - Bruce /*somdcomputerguy */ If you change the way you look at things, the things you look at change. Link to comment Share on other sites More sharing options...
LinuxRabbit Posted August 5, 2009 Author Share Posted August 5, 2009 (edited) Melba, thank you very much, did exactly what I needed it to do. Now I can work on making my gui look nice now that everything works. edit: Oh yeah by the way Melba, you give the best examples out there when posting. Everything so clean and easy to see changes. Edited August 5, 2009 by LinuxRabbit 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