ScriptUSER Posted March 7, 2007 Posted March 7, 2007 I am trying to find string in the list box ... working trying to select it .. not working atempting to get selected text ... not working CODE$ret = _GUICtrlListFindString ($listbox, GUICtrlRead($input)) MsgBox(16,"position",$ret) _GUICtrlListSetSel($listbox,1,$ret) $ret = _GUICtrlListGetText ($listbox, _GUICtrlListSelectedIndex ($listbox)) MsgBox(16,"get text",$ret)
_Kurt Posted March 7, 2007 Posted March 7, 2007 (edited) Here's what I would use: Local $index = 0 For $i = 0 To _GUICtrlListCount($listbox) If $index = 0 Then If NOT StringInStr(_GUICtrlListGetText($listbox, $i), "String") = 0 Then $index = $i EndIf Next _GUICtrlListSetSel($listbox, 1, $index) $text = _GUICtrlListGetText($listbox, $index) Msgbox(0,"",$text) Basically selects the first list item that contains the string. Kurt EDIT: Fixed Minor Mistake Edited March 7, 2007 by _Kurt Awaiting Diablo III..
BrettF Posted March 7, 2007 Posted March 7, 2007 Im lost on what you are trying to achive..... Vist my blog!UDFs: Opens The Default Mail Client | _LoginBox | Convert Reg to AU3 | BASS.au3 (BASS.dll) (Includes various BASS Libraries) | MultiLang.au3 (Multi-Language GUIs!)Example Scripts: Computer Info Telnet Server | "Secure" HTTP Server (Based on Manadar's Server)Software: AAMP- Advanced AutoIt Media Player | WorldCam | AYTU - Youtube Uploader Tutorials: Learning to Script with AutoIt V3Projects (Hardware + AutoIt): ArduinoUseful Links: AutoIt 1-2-3 | The AutoIt Downloads Section: | SciTE4AutoIt3 Full Version!
_Kurt Posted March 7, 2007 Posted March 7, 2007 My example posted above should work. Awaiting Diablo III..
ScriptUSER Posted March 7, 2007 Author Posted March 7, 2007 My example posted above should work.not working for me would you mind to show me example beginning from this :$ret = _GUICtrlListFindString ($listbox, GUICtrlRead($input)) ; working i want to return yhe index and select it
Moderators SmOke_N Posted March 7, 2007 Moderators Posted March 7, 2007 not working for me would you mind to show me example beginning from this :$ret = _GUICtrlListFindString ($listbox, GUICtrlRead($input)) ; working i want to return yhe index and select itDo yourself a favor, post a working example with a List control filled in, and show the text you want to find and select... and you'd probably get the answer that suits your needs. Don't make others go out of their way to help you by having to do that themselves. Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.
_Kurt Posted March 7, 2007 Posted March 7, 2007 Do yourself a favor, post a working example with a List control filled in, and show the text you want to find and select... and you'd probably get the answer that suits your needs. Don't make others go out of their way to help you by having to do that themselves.I agree, form a simple example so we know exactly what you want.Kurt Awaiting Diablo III..
ScriptUSER Posted March 7, 2007 Author Posted March 7, 2007 I agree, form a simple example so we know exactly what you want.KurtResolved ... I was too Lazy .. to understand .. CODEIf (StringLen(GUICtrlRead($input)) > 0) Then $ret = _GUICtrlListSelectString ($listbox, GUICtrlRead($input), 3) If ($ret == $LB_ERR) Then MsgBox(16, "Error", "Not Found")Else GUICtrlSetData($label, "Item #: " & $ret) $ret = _GUICtrlListSelectedIndex ($listbox)MsgBox(16, "index", $ret) $ret = _GUICtrlListGetText ($listbox, _GUICtrlListSelectedIndex ($listbox))MsgBox(16, "text", $ret) EndIfendif
_Kurt Posted March 7, 2007 Posted March 7, 2007 See, aren't you glad you solved this one on your own? Kurt Awaiting Diablo III..
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