motionman95 Posted May 4, 2009 Share Posted May 4, 2009 Hello!I'm trying to read a listview for items that match my search criteria. Of course, there's the _GUICtrlListView_FindInText and other function the help with this problem. The only problem is that I wish to return all the items that match my criteria, and not just the first one the function comes to. I came up with this, but its fault is the fact that it shows some results more than once:Func searchWindows() $itemNum = _GUICtrlListView_FindInText(GUICtrlGetHandle($WinListView), GUICtrlRead($Search_Box)) $i = 0 While $itemNum > -1 AND $i < _GUICtrlListView_GetItemCount($WinListView) $itemNum = _GUICtrlListView_FindInText(GUICtrlGetHandle($WinListView), GUICtrlRead($Search_Box), $itemNum) ConsoleWrite($itemNum & " Text: " & _GUICtrlListView_GetItemText($WinListView, $itemNum, 1) & @CRLF) $i += 1 WEnd EndFunc ;==>searchWindowsThanks in advance,I can't wait to see your responses! Link to comment Share on other sites More sharing options...
Zinthose Posted May 4, 2009 Share Posted May 4, 2009 I haven't tested it but... Func searchWindows() Local $itemNum = -1 While True $itemNum = _GUICtrlListView_FindInText(GUICtrlGetHandle($WinListView), GUICtrlRead($Search_Box), $itemNum) If $itemNum = -1 Then ExitLoop ConsoleWrite($itemNum & " Text: " & _GUICtrlListView_GetItemText($WinListView, $itemNum, 1) & @CRLF) WEnd EndFunc ;==>searchWindows The "_GUICtrlListView_FindInText" function has a the $iStart param to specify a search start location. --- TTFN Link to comment Share on other sites More sharing options...
BrettF Posted May 4, 2009 Share Posted May 4, 2009 How do you populate the list view? 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! Link to comment Share on other sites More sharing options...
motionman95 Posted May 4, 2009 Author Share Posted May 4, 2009 @Zinthose:Your code doesn't work. Is just loops and displays the same lines over and over again.Off topic:Did you happen to get your username from Raven?@BrettF: _GUICtrlListView_AddItem() and _GUICtrlListView_AddSubItem() Link to comment Share on other sites More sharing options...
Zinthose Posted May 4, 2009 Share Posted May 4, 2009 (edited) Ok, I found the problem.. I needed to disable the wrap feature. /doh expandcollapse popup#include 'ButtonConstants.au3' #include 'EditConstants.au3' #include 'GUIConstantsEx.au3' #include 'ListViewConstants.au3' #include 'WindowsConstants.au3' #include 'GuiListView.au3' #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 625, 445, -999, 144) $WinListView = GUICtrlCreateListView("", 0, 0, 624, 409) $Search_Box = GUICtrlCreateInput("Col 2", 0, 408, 505, 21) $Search = GUICtrlCreateButton("Search", 504, 408, 75, 25, 0) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### _GUICtrlListView_InsertColumn($WinListView, 0, "Column 1", 100) _GUICtrlListView_InsertColumn($WinListView, 1, "Column 2", 100) _GUICtrlListView_InsertColumn($WinListView, 2, "Column 3", 100) _GUICtrlListView_AddItem($WinListView, "Row 1: Col 1", 0) _GUICtrlListView_AddSubItem($WinListView, 0, "Row 1: Col 2", 1, 1) _GUICtrlListView_AddSubItem($WinListView, 0, "Row 1: Col 3", 2, 2) _GUICtrlListView_AddItem($WinListView, "Row 2: Col 1", 1) _GUICtrlListView_AddSubItem($WinListView, 1, "Row 2: Col 2", 1, 2) _GUICtrlListView_AddItem($WinListView, "Row 3: Col 1", 2) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Search searchWindows() EndSwitch WEnd Func searchWindows() Local $itemNum = -1 While True $itemNum = _GUICtrlListView_FindInText(GUICtrlGetHandle($WinListView), GUICtrlRead($Search_Box), $itemNum, False) If @error or $itemNum = -1 Then ExitLoop ConsoleWrite($itemNum & " Text: " & _GUICtrlListView_GetItemText($WinListView, $itemNum, 1) & @CRLF) WEnd EndFunc ;==>searchWindows p.s. Yes, Raven's little chant is the source of my name Edited May 4, 2009 by Zinthose --- TTFN Link to comment Share on other sites More sharing options...
motionman95 Posted May 4, 2009 Author Share Posted May 4, 2009 @Zinthose: It doesn't work whether I leave the +1 there or not. =( Link to comment Share on other sites More sharing options...
BrettF Posted May 4, 2009 Share Posted May 4, 2009 Do you populate it from an array? Why not search an array? 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! Link to comment Share on other sites More sharing options...
Zinthose Posted May 4, 2009 Share Posted May 4, 2009 I fixed it... see last edited post --- TTFN 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