Jump to content

Listbox occurence text


erggre
 Share

Recommended Posts

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 retreive

the 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

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

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

  • 2 weeks later...

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
EndIf

For 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 by erggre
Link to comment
Share on other sites

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 by Piano_Man
My Programs[list][*]Knight Media Player[*]Multiple Desktops[*]Daily Comics[*]Journal[/list]
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...