aerb Posted January 31, 2012 Share Posted January 31, 2012 (edited) Hi am relative newb, and want to create a combo (or list) box, to select a value and pass to a variable. Have previously used a messy msgbox for this but want to tidy up. Have been trawling through various help files and forums but answers look over complicated. e.g. $Message="Please enter your location and click OK" & @LF & @LF & "an = Andover" & @lf & "be = Berwick" & @LF & "pu = Bockhampton" & @lf & "bo = Bourne" & @lf & "cr = Cranswick" & @lf & "di = Diss" & @LF & @LF $bLoop = 1 While $bLoop = 1 $text = InputBox("Online Installer", $Message, "", " M2", 250, 330) If @error = 1 Then MsgBox(4100, "Error", "You pressed 'Cancel' - try again!") Else Select Case $text = "an" $answer = MsgBox(4, "Andover", "You typed in Andover! OK?") $disks = "ITANDO" If $answer = 6 Then ExitLoop EndIf Case $text = "bo" $answer = MsgBox(4, "Bourne", "You typed in Bourne! OK?") $disks = "ITBOUR" If $answer = 6 Then ExitLoop EndIf Case $text = "be" $answer = MsgBox(4, "Berwick", "You typed in Berwick! OK?") $disks = "ITBERW" If $answer = 6 Then ExitLoop EndIf Case $text = "cr" $answer = MsgBox(4, "Cranswick", "You typed in Cranswick! OK?") $disks = "ITCRAN" If $answer = 6 Then ExitLoop EndIf Case $text = "di" $answer = MsgBox(4, "Diss", "You typed in Diss! OK?") $disks = "ITDISS" If $answer = 6 Then ExitLoop EndIf EndSelect any help would be great, thanks Edited January 31, 2012 by aerb Link to comment Share on other sites More sharing options...
Syed23 Posted February 1, 2012 Share Posted February 1, 2012 looking for something like this? [autoit] #include <GUIConstantsEx.au3> $GUI = GUICreate("My GUI combo") ; will create a dialog box that when displayed is centered $Combo = GUICtrlCreateCombo("", 10, 10) ; create first item GUICtrlSetData(-1, "Andover|Berwick|Bockhampton|Bourne|Cranswick|Diss") ; add other item snd set a new default $n2 = GUICtrlCreateButton("Read",70,70,40,40) GUISetState() ; Run the GUI until the dialog is closed While 1 $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then ExitLoop If $msg= $n2 Then If GUICtrlRead($Combo) = "Andover" Then MsgBox(0,"","Test Andover") EndIf If GUICtrlRead($Combo) = "Berwick" Then MsgBox(0,"","Test Berwick") EndIf If GUICtrlRead($Combo) = "Bockhampton" Then MsgBox(0,"","Test Bockhampton") EndIf If GUICtrlRead($Combo) = "Bourne" Then MsgBox(0,"","Test Bourne") EndIf If GUICtrlRead($Combo) = "Cranswick" Then MsgBox(0,"","Test Cranswick") EndIf If GUICtrlRead($Combo) = "Diss" Then MsgBox(0,"","Test Diss") EndIf EndIf WEnd [autoit] Thank you,Regards,[font="Garamond"][size="4"]K.Syed Ibrahim.[/size][/font] Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted February 1, 2012 Moderators Share Posted February 1, 2012 (edited) aerb,Or you could rid of the If statements altogether like this: #include <guiconstantsex.au3> $hGUI = GUICreate("My GUI combo") $hCombo = GUICtrlCreateCombo("", 10, 10) GUICtrlSetData(-1, "Andover|Berwick|Bockhampton|Bourne|Cranswick|Diss") $hButton = GUICtrlCreateButton("Read", 70, 70, 40, 40) GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $hButton Switch GUICtrlRead($hCombo) Case "Andover" MsgBox(0, "", "Test Andover") Case "Berwick" MsgBox(0, "", "Test Berwick") Case "Bockhampton" MsgBox(0, "", "Test Bockhampton") Case "Bourne" MsgBox(0, "", "Test Bourne") Case "Cranswick" MsgBox(0, "", "Test Cranswick") Case "Diss" MsgBox(0, "", "Test Diss") EndSwitch EndSwitch WEndPlease ask if you have any questions. M23P.S. When you post code please use Code tags. Put [autoit] before and [/autoit] after your posted code.Edit: Just noticed this is my 10,000th post. Edited February 1, 2012 by Melba23 Syed23 1 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...
water Posted February 1, 2012 Share Posted February 1, 2012 Wow, congratulation to this amount of posts. Printed on paper it would be quite a big pile My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki Link to comment Share on other sites More sharing options...
Syed23 Posted February 1, 2012 Share Posted February 1, 2012 (edited) P.S. When you post code please use Code tags. Put [autoit][/autoit] after your posted code. Congrats Melba!!! when i replied, i used the tags but it did not works some times Edited February 1, 2012 by Syed23 Thank you,Regards,[font="Garamond"][size="4"]K.Syed Ibrahim.[/size][/font] 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