Reinhardt1julian Posted January 23, 2014 Share Posted January 23, 2014 Is it possible to use _GUICtrlListView_FindInText on multiple coulmns? For example if a listview item is "item1|item2" and another item is "item1|item3" And a third one is "item2|item3" and I am trying to get the index of the "item1|item3" item, is that possible with jsut that function? If not, what happens if I search for "item1" and it gives me 2 results? Thank you reinhardt1julian Link to comment Share on other sites More sharing options...
jdelaney Posted January 23, 2014 Share Posted January 23, 2014 (edited) Something like this: ;~ _GUICtrlListView_GetItemTextArray to populate $aArray...manually creating to demonstrate Local $aArray[3][2] = [["item1","item2"],["item2","item3"],["item1","item3"]] Local $aArrayToFind[2] = ["item1","item3"] Local $bFound For $i = 0 To UBound($aArray)-1 $bFound = ($aArray[$i][0]=$aArrayToFind[0]) And ($aArray[$i][1]=$aArrayToFind[1]) If $bFound Then ExitLoop Next If $bFound Then ConsoleWrite("item found matching at: " & $i & @CRLF) Else ConsoleWrite("item not found" & @CRLF) EndIf Output: item found matching at: 2 I lied. the function above won't return what's needed...this works: #include <GUIConstantsEx.au3> #include <GuiListView.au3> Local $aArrayToFind[2] = ["item1","item3"] Local $bFound GUICreate("ListView Get Item Text Array", 400, 300) $hListView = GUICtrlCreateListView("col1|col2", 2, 2, 394, 268) GUICtrlCreateListViewItem("item1|item2", $hListView) GUICtrlCreateListViewItem("item2|item3", $hListView) GUICtrlCreateListViewItem("item1|item3", $hListView) $iItems = _GUICtrlListView_GetItemCount($hListView) $iCols = _GUICtrlListView_GetColumnCount($hListView) Local $aArray[$iItems] For $i = 0 To UBound($aArray)-1 $aArray[$i] = StringSplit(_GUICtrlListView_GetItemTextString($hListView,$i),"|",2) Next For $i = 0 To UBound($aArray)-1 $aTemp = $aArray[$i] $bFound = ($aTemp[0]=$aArrayToFind[0]) And ($aTemp[1]=$aArrayToFind[1]) If $bFound Then ExitLoop Next If $bFound Then ConsoleWrite("item found matching at: " & $i & @CRLF) Else ConsoleWrite("item not found" & @CRLF) EndIf Edited January 23, 2014 by jdelaney IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window. Link to comment Share on other sites More sharing options...
mikell Posted January 23, 2014 Share Posted January 23, 2014 Auld style Local $sTextToFind = "item2|item3" $gui = GUICreate("ListView Get Item Text Array", 400, 300) $hListView = GUICtrlCreateListView("col1|col2", 2, 2, 394, 268) GUICtrlCreateListViewItem("item1|item2", $hListView) GUICtrlCreateListViewItem("item2|item3", $hListView) GUICtrlCreateListViewItem("item1|item3", $hListView) GuiSetState() $iItems = ControlListView($gui, "", $hListView, "GetItemCount") For $i = 0 To $iItems-1 ControlListView($gui, "", $hListView, "Select", $i) If StringInStr(GuiCtrlRead(GuiCtrlRead($hListView)), $sTextToFind) Then Exitloop Next Msgbox(0,"", "item found matching at: " & $i ) 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