thenewkid Posted September 28, 2007 Share Posted September 28, 2007 (edited) hi ive been useing guicrtlread for a combo box and then writeing the data to a .ini but when i save it. it saves as a number does any one know how to fix it thanks Edited September 28, 2007 by thenewkid some of my scripts check them out and give feedback so i can learn from them :)autoclicker a autoclickernote taker a script to take notes with Link to comment Share on other sites More sharing options...
ssubirias3 Posted September 28, 2007 Share Posted September 28, 2007 It really is helpful to include some code. My guess would be that you're using function incorrectly. For example: #include <GUIConstants.au3> $Gui1 = GUICreate("So What??", 251, 85, 193, 115) $Label1 = GUICtrlCreateLabel("What color is Red?", 8, 12, 95, 17) $Input1 = GUICtrlCreateInput("", 7, 37, 161, 21) GUICtrlSetTip(-1, "AInput1") GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Input1 If GUICtrlRead($Input1) == "Red" Or "red" Then MsgBox(0, "Correct", "Cool, you know " & GUICtrlRead($Input1) & " is Red!") Else MsgBox(0, "Wrong", "Good going George! Thanks for the war, buddy!") EndIf EndSwitch Sleep(40) WEnd Link to comment Share on other sites More sharing options...
aslani Posted September 28, 2007 Share Posted September 28, 2007 (edited) If you want to save what your GUICtrlRead() have read, you have to give GUICtrlRead() a variable. Example: $input = GUICtrlCreateInput("", $x_align, $y_align) $get_input = GUICtrlRead($input) And make sure that you are saving $get_input and not $input, else you'll get the number. Edited September 28, 2007 by aslani [font="Georgia"]Chances are, I'm wrong.[/font]HotKey trouble?Stringregexp GuideAutoIT Current Version Link to comment Share on other sites More sharing options...
ssubirias3 Posted September 28, 2007 Share Posted September 28, 2007 ... you have to give GUICtrlRead() a variable ... else you'll get the number.Really?? I'm pretty new at this stuff and especially the GUI stuff. Can you explain this a little more? In the code I posted earlier, I did not use a variable and the MsgBox displays the value entered ... not a number. Thanks in advance for the clarification . Link to comment Share on other sites More sharing options...
PsaltyDS Posted September 29, 2007 Share Posted September 29, 2007 (edited) Well the OP was about a COMBO control being read...Here's the demo:#include <GUIConstants.au3> GUICreate("My GUI combo", 300, 100) $Combo = GUICtrlCreateCombo ("item1", 10,10, 280) ; create first item GUICtrlSetData(-1,"item2|item3|item4","item3") ; add other items and set default $Button = GUICtrlCreateButton("Read", 100, 60, 100, 30) GUISetState () ; Run the GUI until the dialog is closed While 1 Switch GUIGetMsg() Case $Button $Val = GUICtrlRead($Combo) MsgBox(64, "Read Combo", "Combo selection = " & $val) Case $GUI_EVENT_CLOSE Exit EndSwitch WendNote that $Combo only contains the ControlID for the combo control, not the data. When GuiCtrlRead() is used, the control ID given tells it which control to read, and the selected item's text is returned, saved to $Val, and displayed. Of course you can save $Val to a file instead of displaying it. Edited September 29, 2007 by PsaltyDS Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
ssubirias3 Posted September 29, 2007 Share Posted September 29, 2007 Well the OP was about a COMBO control being read... Note that $Combo only contains the ControlID for the combo control, not the data. When GuiCtrlRead() is used, the control ID given tells it which control to read, and the selected item's text is returned, saved to $Val, and displayed. Of course you can save $Val to a file instead of displaying it.First aslani and now you PsaltyDS ... yeah, yeah, the OP (thenewkid) said combo, but the point is GUICTRLREAD() works the same way with any of the controls, right?? That's not counting the optional "advanced" parameter of course. Shouldn't that be the focus of the conversation? After all thenewkid didn't even both to offer any code, but wants some help??? What's up with that??? I'm still waiting for a good explaination why GuiCtrlRead() has to be assigned a variable in order to work. Just for fun, and prove I'm not completely crazy... I've modified my orginial code from an INPUT to a COMBO. Still same net effect, no variable tied to GuiCtrlRead() yet the MsgBox() displays the value selected and not a number. #include <GUIConstants.au3> $Gui1 = GUICreate("So What??", 251, 85, 193, 115) $Label1 = GUICtrlCreateLabel("What color is Red?", 8, 12, 95, 17) $Input1 = GUICtrlCreateCombo("", 7, 37, 161, 21) GUICtrlSetData(-1, "Green|Yellow|Purple|Red|Cobalt", "") GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Input1 If GUICtrlRead($Input1) == "Red" Then MsgBox(0, "Correct", "Cool, you know " & GUICtrlRead($Input1) & " is Red!") Else MsgBox(0, "Wrong", "Good going George! Thanks for the war, buddy!") EndIf EndSwitch Sleep(40) WEnd Link to comment Share on other sites More sharing options...
PsaltyDS Posted September 29, 2007 Share Posted September 29, 2007 I'm still waiting for a good explaination why GuiCtrlRead() has to be assigned a variable in order to work.There's the part I don't understand about the line of conversation, I guess. The code I posted works. Your code above works. What is it that doesn't work or needs explanation? Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law 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