megahyperion Posted October 23, 2004 Posted October 23, 2004 Ok if you read my first thread here you already know that I'm a newb. I have been playing with scripting for 2 weeks now, so please cut me some slack : Here is what I want to do, I want a combo box style drop down box with three options. The user selects the option then I would like a return value of 1 for the option that has been selected and a return value of 0 for the other 2. I have tried a million things (well not a million) and I have been using the message box to try to get what I want, then later I can use it how I want it. Here is one of my 10 scripts I was playing with. Global $CBS_DROPDOWNLIST= 3 Global $ES_READONLY= 2048 Global $LBS_STANDARD= 10485763 $GUI_EVENT_CLOSE= -3 #include <GUIConstants.au3> GUICreate("My GUI") GUICtrlCreateCombo ("", 10, 10, 100, 80, BitOR($ES_READONLY, $CBS_DROPDOWNLIST, $LBS_STANDARD)) $combo = GUICtrlSetData(-1,"item1") $combo2 = GUICtrlSetData(-1,"item2") $combo3 = GUICtrlSetData(-1,"item3") $OK = GUICtrlCreateButton ("OK", 188, 325, 60, 25) GUISetState () While 1 $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then ExitLoop If $msg = $OK Then Msgbox(0,"NFO", $combo & @CRLF & $combo2 & @CRLF & $combo3) Wend You can see that I only get the value 3 for each one? This was the only way I could get three seperate values. Here is the way the autoit help file says to do , but I dont even know how to get three seperate $combo values. Global $CBS_DROPDOWNLIST= 3 Global $ES_READONLY= 2048 Global $LBS_STANDARD= 10485763 $GUI_EVENT_CLOSE= -3 #include <GUIConstants.au3> GUICreate("My GUI") $combo = GUICtrlCreateCombo ("", 10, 10, 100, 80, BitOR($ES_READONLY, $CBS_DROPDOWNLIST, $LBS_STANDARD)) GUICtrlSetData($combo,"item1|item2|item3") $OK = GUICtrlCreateButton ("OK", 188, 325, 60, 25) GUISetState () While 1 $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then ExitLoop If $msg = $OK Then Msgbox(0,"NFO", $combo) Wend any help would be great.
Josbe Posted October 23, 2004 Posted October 23, 2004 (edited) Look about: GUIRead function.Global $CBS_DROPDOWNLIST= 3 Global $ES_READONLY= 2048 Global $LBS_STANDARD= 10485763 $GUI_EVENT_CLOSE= -3 #include <GUIConstants.au3> GUICreate("My GUI") $CTRL_combo= GUICtrlCreateCombo ("", 10, 10, 100, 80, BitOR($ES_READONLY, $CBS_DROPDOWNLIST, $LBS_STANDARD)) $combo = GUICtrlSetData(-1,"item1|item2|item3", "item1") $OK = GUICtrlCreateButton ("OK", 188, 325, 60, 25) GUISetState () While 1 $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then ExitLoop If $msg = $OK Then Msgbox(0,"NFO", "You selected: " & GUIRead($CTRL_combo)) Wend ExitI don't sure, what you said in this line. Maybe item's index? Quote The user selects the option then I would like a return value of 1 for the option that has been selected and a return value of 0 for the other 2. Edited October 23, 2004 by josbe AUTOIT > AutoIt docs / Beta folder - AutoIt latest beta
megahyperion Posted October 23, 2004 Author Posted October 23, 2004 GUIRead will just read the text in the box, i.e. item1, item2, item3, etc.... But it wont give me a number response such as 1 or 0 , true or false. For example look at my button and how when clicked it will do anything I want. Mine opens a message box. What I would like is when a selection is made in the combo box for it to trigger something, anything. but not until the ok button is clicked. Other wise it would be doing something every single time you changed your mind on the selection or if you where bored and just playing with the button.
CyberSlug Posted October 23, 2004 Posted October 23, 2004 By the way, http://www.autoitscript.com/fileman/users/public/CyberSlug/lb_wrappers_self-contained.au3. The corresponding functions for combobox controls are different, but I can work on them soon....Global $CBS_DROPDOWNLIST= 3, $ES_READONLY= 2048, $LBS_STANDARD= 10485763, $GUI_EVENT_CLOSE= -3 #include <GUIConstants.au3> GUICreate("My GUI") $combo = GUICtrlCreateCombo ("", 10, 10, 100, 80, BitOR($ES_READONLY, $CBS_DROPDOWNLIST, $LBS_STANDARD)) GUICtrlSetData(-1,"itemZero|itemOne|itemTwo|itemThree") $OK = GUICtrlCreateButton ("OK", 188, 325, 60, 25) GUISetState () While 1 $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then ExitLoop If $msg = $OK Then MsgBox(4096,"sel index", _GuiCB_GetcurSel($combo)) EndIf Wend ; Maybe this might help Func _GuiCB_GetCurSel($ref) Return GuiSendMsg($ref, 0x147, 0, 0);CB_GETCURSEL EndFunc Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig!
megahyperion Posted October 24, 2004 Author Posted October 24, 2004 Damn you. Just kidding, I swapped out the combo box for 3 radio buttons. maybe I will put it back in, I dunno. I did the radio buttons staggered and its kinda growing on me. But I see you made the combo box work pretty much how I wanted it to work. Here is an example of my staggered radio script #include <GUIConstants.au3> GUICreate("My GUI group") ; will create a dialog box that when displayed is centered GUICtrlCreateGroup ("My staggered Radio", 178, 80, 160, 100) $res1 = GUICtrlCreateRadio ("item 1", 200, 100, 60, 20) $res2 = GUICtrlCreateRadio ("item 2", 223, 125, 60, 20) $res3 = GUICtrlCreateRadio ("item 3", 245, 150, 60, 20) GUICtrlCreateGroup ("",-99,-99,1,1) GUISetState () ; will display an empty dialog box ; Run the GUI until the dialog is closed While 1 $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then ExitLoop Wend
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