erggre Posted October 25, 2007 Share Posted October 25, 2007 Hi all,I am trying to retreive the text of every occurence in my listbox.So, I was hoping to be able to retreive the number of occurence in my listbox,be able to make a loop that would select the occurence one at a time and retreivethe text. So far, the best command I found was ("SetCurrentSelection", occurrence") but it acted like I was double clicking the selection wich is not wanted here.Any suggestions?Thanks! Link to comment Share on other sites More sharing options...
Achilles Posted October 25, 2007 Share Posted October 25, 2007 Look at these in the helpfile: _GUICtrlListGetText() _GUICtrlListCount() You'll probably want something like this: #include <GuiList.au3>;include the function that start with _GuiCtrlList.. For $index = 1 to _GuiCtrlListCount($listbox);go through all items in the list If StringInStr(_GuiCtrlListGetText($listbox, $index), 'the') <> 0 then;if the text 'the' is in the current row being checked _GUICtrlListSetSel($listbox, 1, $index);select it Sleep(1000);wait a second so the user can see that it's there Next My Programs[list][*]Knight Media Player[*]Multiple Desktops[*]Daily Comics[*]Journal[/list] Link to comment Share on other sites More sharing options...
erggre Posted October 25, 2007 Author Share Posted October 25, 2007 Look at these in the helpfile: _GUICtrlListGetText() _GUICtrlListCount() You'll probably want something like this: #include <GuiList.au3>;include the function that start with _GuiCtrlList.. For $index = 1 to _GuiCtrlListCount($listbox);go through all items in the list If StringInStr(_GuiCtrlListGetText($listbox, $index), 'the') <> 0 then;if the text 'the' is in the current row being checked _GUICtrlListSetSel($listbox, 1, $index);select it Sleep(1000);wait a second so the user can see that it's there Next Exactly what I needed! Thanks a lot Link to comment Share on other sites More sharing options...
erggre Posted November 7, 2007 Author Share Posted November 7, 2007 (edited) Here's a piece of code using the code suggested above:$ListBoxHandle = ControlGetHandle ( "My window containing a list box", "", 1005 ); If ( $ListBoxHandle <> "" ) Then $itemNbr = _GuiCtrlListCount($ListBoxHandle); ConsoleWrite ( "Number of item: " & $itemNbr & @CRLF); For $index = 0 to $itemNbr - 1; If StringInStr(_GuiCtrlListGetText($ListBoxHandle, $index), $MatchTableName) <> 0 then $ret = _GUICtrlListSetSel($ListBoxHandle, 1, $index); Select it If ($ret == $LB_ERR) Then MsgBox(16, "Error", "Unknown error from _GUICtrlListSelectIndex") EndIf EndIf Next EndIfFor an unknown reason, I keep getting the message box telling me that there is an error.Function GuiCtrlListCount is returning the right number of item.Can someone help me find the possible cause of this function returning an error?Thanks Edited November 7, 2007 by erggre Link to comment Share on other sites More sharing options...
Achilles Posted November 7, 2007 Share Posted November 7, 2007 (edited) I'm afraid that you can't do what you're trying to do the way you're trying to do it. Getting the handle of the listview does not mean that it is a Gui object you can use. Consequently you can't use functions like _GuiCtrl* with it.Try looking in the beta helpfile for some examples of listviews that are not made in AutoIt. (If not in beta try AutoItlib, I'm not sure where they are anymore)EDIT: Function GuiCtrlListCount is returning the right number of item.Are you sure that's working the way it's supposed to? I was pretty sure it shouldn't Edited November 7, 2007 by Piano_Man My Programs[list][*]Knight Media Player[*]Multiple Desktops[*]Daily Comics[*]Journal[/list] Link to comment Share on other sites More sharing options...
erggre Posted November 7, 2007 Author Share Posted November 7, 2007 I found this file in auto3lib "A3LListbox.au3"I didn't try anything inside this file yet, but I guess this was what you wererefering to.So those functions are use for listbox that are not created by the autoit GUI right? 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