kiffab Posted March 25, 2011 Share Posted March 25, 2011 Hello AutoIt noob here... looking for some assistance with an app I've built. I'm replacing my input boxes with a combo box with several items listed. To do this, I used the code: $hostname = _GUICtrlComboBox_Create($myGUI, "item1|item2|item3", 110, 70, 170, 20) I can then click on the drop down arrow and choose one of the items. However, I'm unsure how I could then write the contents of the box to the file. Trying to display the $hostname output in a msgbox results in either a blank string or a 0. Another strange problem I have is that some I can click on all but 1 of my input boxes. I have no idea why. Thanks in advance for any help Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted March 25, 2011 Moderators Share Posted March 25, 2011 kiffab,Welcome to the AutoIt forum. You need to use GUICtrlRead to get the contents of your combo - and then FileWrite or FileWriteLine to get that value into a file.As to the recalcitrant input box, please post your code and we will take a look - it is a bit difficult to debug at distance as the crystal balls are not too reliable these days. When you post your code please use Code tags - just put [autoit] before and [/autoit] after your posted code. 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...
kiffab Posted March 25, 2011 Author Share Posted March 25, 2011 Thanks for the prompt response. Here you go... Notice file path 3 is not clickable. Not sure why. I also try to read the contents of hostname but it says "0". expandcollapse popup#include <GUIComboBox.au3> #include <GuiConstantsEx.au3> #include <WindowsConstants.au3> #include <Constants.au3> #include <StaticConstants.au3> Global $btn[5] GUI() Func GUI() Local $myGUI, $msg, $hostname, $database, $server, $username, $password, $fp1, $fp2, $fp3, $font, $sIni, $msgbox $myGUI = GUICreate("app", 500, 400) GUISetBkColor(0xe9CADC3) GUISetFont(8, 1, 3, "verdana") GUICtrlCreateLabel("Hostname", 60, 10, 60, 20) $hostname = _GUICtrlComboBox_Create($myGUI, "Server1|Server2|Server3", 20, 30, 120, 20) GUICtrlCreateLabel("Username", 180, 10, 60, 20) $logon = _GUICtrlComboBox_Create($myGUI, "user1|user2|user3", 150, 30, 120, 20) GUICtrlCreateLabel("Password", 310, 10, 60, 20) $password = GUICtrlCreateInput("", 280, 30, 120, 20) GUICtrlCreateLabel("Database", 60, 75, 120, 20) $database = _GUICtrlComboBox_Create($myGUI, "db1|db2|db3", 110, 70, 170, 20) GUICtrlCreateLabel("FilePath1", 30, 225, 100, 20) $fp1 = GUICtrlCreateInput("", 110, 225, 230, 20) GUICtrlCreateLabel("FilePath2", 30, 245, 100, 20) $fp2 = GUICtrlCreateInput("", 110, 245, 230, 20) GUICtrlCreateLabel("FilePath3", 30, 265, 315, 20) $fp3 = GUICtrlCreateInput("", 110, 265, 230, 20) $btn[0] = GUICtrlCreateButton("read hostname", 370, 185, 80, 30) $btn[1] = GUICtrlCreateButton("button2", 370, 215, 80, 30) $btn[2] = GUICtrlCreateButton("button3", 370, 245, 80, 30) $btn[3] = GUICtrlCreateButton("button4", 370, 275, 80, 30) $btn[4] = GUICtrlCreateButton("Exit", 370, 305, 80, 30) GUISetState() Do $msg = GUIGetMsg() If $msg = $btn[0] Then msgBox(4160, "box",GUICtrlRead($hostname)) EndIf If $msg = $btn[4] Then Exit EndIf Until $msg = $GUI_EVENT_CLOSE ;GUISetState(@SW_SHOW, $myGUI) EndFunc Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted March 25, 2011 Moderators Share Posted March 25, 2011 kiffab,Pretty simple to sort that one out for you! - 1. I would recommend that you use the native functions to create controls if you can - it makes everything much easier. You were using the UDF combo creation function, which means you have to use the other UDF functions to interact with it. If you create your controls with the native functions, you can use the native functions to interact. Keep the UDF functions for when you need the additional functionality they offer in more advanced scripts. - 2. You could not click your input as the label was 315 pixels wide and so overlapped with the input. If you have overlapping controls, AutoIt does not know which you are actioning and so refuses to action either! Here is the amended code - look for the <<<<<<<<<<<< lines:expandcollapse popup#include <GUIComboBox.au3> #include <GuiConstantsEx.au3> #include <WindowsConstants.au3> #include <Constants.au3> #include <StaticConstants.au3> Global $btn[5] GUI() Func GUI() Local $myGUI, $msg, $hostname, $database, $server, $username, $password, $fp1, $fp2, $fp3, $font, $sIni, $msgbox $myGUI = GUICreate("app", 500, 400) GUISetBkColor(0xe9CADC3) GUISetFont(8, 1, 3, "verdana") GUICtrlCreateLabel("Hostname", 60, 10, 60, 20) $hostname = GUICtrlCreateCombo("", 20, 30, 120, 20) ; <<<<<<<<<<<<<<<<<<<<<<<<< GUICtrlSetData(-1, "Server1|Server2|Server3") ; <<<<<<<<<<<<<<<<<<<<<<<<< GUICtrlCreateLabel("Username", 180, 10, 60, 20) $logon = GUICtrlCreateCombo("", 150, 30, 120, 20) ; <<<<<<<<<<<<<<<<<<<<<<<<< GUICtrlSetData(-1, "user1|user2|user3") ; <<<<<<<<<<<<<<<<<<<<<<<<< GUICtrlCreateLabel("Password", 310, 10, 60, 20) $password = GUICtrlCreateInput("", 280, 30, 120, 20) GUICtrlCreateLabel("Database", 60, 75, 120, 20) $database = GUICtrlCreateCombo("", 110, 70, 170, 20) ; <<<<<<<<<<<<<<<<<<<<<<<<< GUICtrlSetData(-1, "db1|db2|db3") ; <<<<<<<<<<<<<<<<<<<<<<<<< GUICtrlCreateLabel("FilePath1", 30, 225, 100, 20) $fp1 = GUICtrlCreateInput("", 110, 225, 230, 20) GUICtrlCreateLabel("FilePath2", 30, 245, 100, 20) $fp2 = GUICtrlCreateInput("", 110, 245, 230, 20) GUICtrlCreateLabel("FilePath3", 30, 265, 100, 20) ; <<<<<<<<<<<<<<<<<<<<<<<<< $fp3 = GUICtrlCreateInput("", 110, 265, 230, 20) $btn[0] = GUICtrlCreateButton("read hostname", 370, 185, 80, 30) $btn[1] = GUICtrlCreateButton("button2", 370, 215, 80, 30) $btn[2] = GUICtrlCreateButton("button3", 370, 245, 80, 30) $btn[3] = GUICtrlCreateButton("button4", 370, 275, 80, 30) $btn[4] = GUICtrlCreateButton("Exit", 370, 305, 80, 30) GUISetState() Do $msg = GUIGetMsg() If $msg = $btn[0] Then msgBox(4160, "box",GUICtrlRead($hostname)) EndIf If $msg = $btn[4] Then Exit EndIf Until $msg = $GUI_EVENT_CLOSE ;GUISetState(@SW_SHOW, $myGUI) EndFuncNote the use of GUICtrlSetData to fill the combos. Please ask if you have any questions. 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...
kiffab Posted March 25, 2011 Author Share Posted March 25, 2011 Thanks very much for showing me the error of my ways!! Tested - working perfectly. Cheers 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