gte Posted May 5, 2009 Share Posted May 5, 2009 I'm trying to assign values to items from a drop down menu, to write code so that if "AM" is chosen, a value is assigned to that and I can parse a time value into a cmd command without needing to alter it, and if "PM" is chosen, I can +12 the first part of the HH:MM:SS of the cmd file and then write it into the string Here is the script I am working with, any thoughts? #include <GUIConstantsEx.au3> Opt('MustDeclareVars', 1) Example() Func Example() Local $msg GUICreate("My GUI") ; will create a dialog box that when displayed is centered GUICtrlCreateCombo("AM or PM?", 10, 10) GUICtrlSetData(-1, "AM|PM", 'AM or PM?') GUISetState() ; will display an empty dialog box with a combo control with focus on ; Run the GUI until the dialog is closed While 1 $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then ExitLoop WEnd EndFunc ;==>Example HP OpenView ServiceCenter keep alive scriptRemote Desktop Login Script Link to comment Share on other sites More sharing options...
weaponx Posted May 5, 2009 Share Posted May 5, 2009 Unfortunately the builtin combobox functions don't allow for key/value combinations. Link to comment Share on other sites More sharing options...
gte Posted May 5, 2009 Author Share Posted May 5, 2009 What do you suggest then?What's the point of having the combobox, if you can't code for values that are selected from it?Unfortunately the builtin combobox functions don't allow for key/value combinations. HP OpenView ServiceCenter keep alive scriptRemote Desktop Login Script Link to comment Share on other sites More sharing options...
Valuater Posted May 5, 2009 Share Posted May 5, 2009 What do you suggest then? What's the point of having the combobox, if you can't code for values that are selected from it? I think this is what you are looking to do!! #include <GUIConstantsEx.au3> GUICreate("My GUI") ; will create a dialog box that when displayed is centered $combo = GUICtrlCreateCombo("AM or PM?", 10, 10) GUICtrlSetData(-1, "AM|PM", 'AM or PM?') GUISetState() While 1 $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then ExitLoop If $msg = $combo Then $cRead = GUICtrlRead($combo) If $cRead = "AM" Then MsgBox(4096, "Test", " You selected AM ", 3) ElseIf $cRead = "PM" Then MsgBox(4096, "Test", " You selected PM ", 3) EndIf EndIf WEnd 8) Link to comment Share on other sites More sharing options...
Bert Posted May 5, 2009 Share Posted May 5, 2009 You beat me to it The Vollatran project  My blog: http://www.vollysinterestingshit.com/ Link to comment Share on other sites More sharing options...
weaponx Posted May 5, 2009 Share Posted May 5, 2009 Honestly i'm not sure why it's like that, its a pain in the ass. I prefer the way they work in html. expandcollapse popup#include <GUIConstantsEx.au3> #include <GUIComboBox.au3> Dim $aData[3][2] $aData[0][0] = "Red" $aData[0][1] = "FF0000" $aData[1][0] = "Green" $aData[1][1] = "00FF00" $aData[2][0] = "Blue" $aData[2][1] = "0000FF" $hGUI = GUICreate("My GUI combo",300,100) ; will create a dialog box that when displayed is centered $hCombo = GUICtrlCreateCombo("", 10, 10,"","",$CBS_DROPDOWNLIST) ;$hCombo = _GUICtrlComboBox_Create($hGUI, "", 2, 2, 296, 20,$CBS_DROPDOWNLIST ) ;Populate For $X = 0 to Ubound($aData)-1 GUICtrlSetData($hCombo,$aData[$X][0]) ;_GUICtrlComboBox_AddString($hCombo,$aData[$X][0]) Next $hButton = GUICtrlCreateButton("Retrieve Value",100,40,100) GUISetState() ; Run the GUI until the dialog is closed While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $hButton MsgBox(0,"",$aData[_GUICtrlComboBox_GetCurSel($hCombo)][1]) EndSwitch WEnd Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted May 5, 2009 Moderators Share Posted May 5, 2009 Val, Could I offer a very slight change to your code to prevent the "AM or PM?" prompt becoming one of the choices in the combo:#include <GUIConstantsEx.au3> #Include <GuiComboBox.au3> GUICreate("My GUI"); will create a dialog box that when displayed is centered $combo = GUICtrlCreateCombo("", 10, 10) GUICtrlSetData(-1, "AM|PM") _GUICtrlComboBox_SetEditText($combo, "AM or PM?") GUISetState() While 1 $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then ExitLoop If $msg = $combo Then $cRead = GUICtrlRead($combo) If $cRead = "AM" Then MsgBox(4096, "Test", " You selected AM ", 3) ElseIf $cRead = "PM" Then MsgBox(4096, "Test", " You selected PM ", 3) EndIf _GUICtrlComboBox_SetEditText($combo, "AM or PM?") EndIf WEnd 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...
Valuater Posted May 5, 2009 Share Posted May 5, 2009 (edited) Val,Could I offer a very slight change to your code to prevent the "AM or PM?" prompt becoming one of the choices in the combo:M23Thanks Melba...Actually that is a "Select" question by the OP. However, my script would not allow that as a selected choice.. 8)EDIT selection to selected Edited May 5, 2009 by Valuater Link to comment Share on other sites More sharing options...
gte Posted May 6, 2009 Author Share Posted May 6, 2009 Thanks all! I'm about to venture into an area I don't even know where to start #include <GUIConstantsEx.au3> #Include <GuiComboBox.au3> GUICreate("My GUI"); will create a dialog box that when displayed is centered $combo = GUICtrlCreateCombo("", 10, 10) GUICtrlSetData(-1, "AM|PM") _GUICtrlComboBox_SetEditText($combo, "AM or PM?") GUISetState() While 1 $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then ExitLoop If $msg = $combo Then $cRead = GUICtrlRead($combo) If $cRead = "AM" Then $ampmvalue = '0' MsgBox(4096, "Test", " You selected AM ", 3) ElseIf $cRead = "PM" Then $ampmvalue= '12' MsgBox(4096, "Test", " You selected PM ", 3) EndIf _GUICtrlComboBox_SetEditText($combo, "AM or PM?") EndIf WEnd And then when they type in a time, say 10:11:12 (for the scheduled task), something will add the $ampmvalue to the first part of the time they type in (in this case 10) . Any thoughts? HP OpenView ServiceCenter keep alive scriptRemote Desktop Login Script Link to comment Share on other sites More sharing options...
TheLandYacht Posted July 17, 2009 Share Posted July 17, 2009 (edited) Two questions about the script mentioned below. By the way, I've edited YOUR original script with a sample of the information I'm looking for. 1. In your example, you select an option in the dropdown menu, then click the RETRIEVE VALUE button to get the result. I am trying to design a similar drop-down menu for non-mouse use, so how would I change this to react to an enter-key press? In other words, use up/down arrows to select the menu item i want, then enter to display the result. 2. WHEN you hit the retrieve value button, it pops up a mini-window with the output. How would you change this to send the output as text to the program behind it(in this case, Cricket Wireless' text messaging software)? These questions are because I am trying to build a simple phonebook for my Cricket Wireless network dongle's text messaging function. I'd like to keep a list of my most often used contacts in a dropdown, so i can just arrow down to the one I want, hit enter, & have the script paste the number into the appropriate field of the Cricket Wireless software. Thanks in advance for any thoughts, and apologies in advance if I've hijacked the thread. Honestly i'm not sure why it's like that, its a pain in the ass. I prefer the way they work in html. expandcollapse popup#include <GUIConstantsEx.au3> #include <GUIComboBox.au3> Dim $aData[3][2] $aData[0][0] = "Joe Smith" $aData[0][1] = "5125551212" $aData[1][0] = "Jim Green" $aData[1][1] = "5125553131" $aData[2][0] = "Sally Fields" $aData[2][1] = "5125556464" $hGUI = GUICreate("My GUI combo",300,100) ; will create a dialog box that when displayed is centered $hCombo = GUICtrlCreateCombo("", 10, 10,"","",$CBS_DROPDOWNLIST) ;$hCombo = _GUICtrlComboBox_Create($hGUI, "", 2, 2, 296, 20,$CBS_DROPDOWNLIST ) ;Populate For $X = 0 to Ubound($aData)-1 GUICtrlSetData($hCombo,$aData[$X][0]) ;_GUICtrlComboBox_AddString($hCombo,$aData[$X][0]) Next $hButton = GUICtrlCreateButton("Retrieve Value",100,40,100) GUISetState() ; Run the GUI until the dialog is closed While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $hButton MsgBox(0,"",$aData[_GUICtrlComboBox_GetCurSel($hCombo)][1]) EndSwitch WEnd Edited July 17, 2009 by TheLandYacht 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