Jump to content

Grabbing Listview


trids
 Share

Recommended Posts

I was also thinking that the ability to state only the items you don't want to select could be useful.

Control...... "selectclear"
Control...... "unselect", "3,12"

<{POST_SNAPBACK}>

... Hmmm, good point about unselecting: maybe we need a "selectall" command as well:

Control...... "selectall"
Control...... "unselect", "3,12"

:ph34r:

Link to comment
Share on other sites

  • Replies 58
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

  • Administrators

Way ahead of ya:

- LV_ItemText, index, subindex

- LV_SelectAll

- LV_SelectClear

- LV_Select, from index, [to index]

- LV_Deselect, from index, [to index]

- LV_GetItemCount

- LV_GetSubItemCount

- LV_IsSelected, index

- LV_GetSelected, [0 = single/first, 1 = multiple delimited by |)

Edited by Jon
Link to comment
Share on other sites

Ohh very nice.

Also will there be a way to have the command only return list entries that have text in them? One of the list's I am working with has 30 list item spaces in it. Usually only 7-10 are used, so I could see that if I didn't know the number of entries and just used "selectall", I would get the first 10 entries with text, but also the next 20 that are empty would be shown as line returns.

Link to comment
Share on other sites

  • 2 weeks later...

This is me playing around with the new listview magic :ph34r: :

;Wait for the folder to be activated, which is named "WWW"
;..and which has 9 shortcuts in it = listitems
    
    WinWaitActive("WWW")
    
    $hWnd = ControlGetHandle("", "", "SysListView321")
msgbox (0,"$hWnd",$hWnd)
    
    $vRet = ControlCommand("","",$hWnd, "LV_GetItemCount")
    $sRet = "" & $vRet & "::"
    $vRet = ControlCommand("","",$hWnd, "LV_GetSubItemCount")
    $sRet = $sRet & $vRet
msgbox (0,"LV_GetItemCount::LV_GetSubItemCount",$sRet)
    
    WinActivate("WWW")
    
    $vRet = ControlCommand("","",$hWnd, "LV_SelectAll")
    Sleep(2000)
    
    $vRet = ControlCommand("","",$hWnd, "LV_SelectClear")
    Sleep(2000)
    
    $vRet = ControlCommand("","",$hWnd, "LV_Select", "5", "9")
    Sleep(2000)
    
    $vRet = ControlCommand("","",$hWnd, "LV_Deselect", "2", "7")
    Sleep(2000)
    
msgbox (0,"","Select some items and i'll tell you which they are")
    $vRet = ControlCommand("","",$hWnd, "LV_GetSelected", "1")
msgbox (0,"LV_GetSelected",$vRet)

    $vRet = ControlCommand("","",$hWnd, "LV_GetItem", "1", "1")
msgbox (0,"LV_GetItem",$vRet)

Questions for Jon or anyone else who knows ..

1. I can't seem to get the LV_GetItem command to work. Any ideas?

2. How do I select items: 2,4,6 and 8 .. in one statement?

3. It would be more consistent if the LV_GetSelected referred to items in the same terms as LV_Select: At the moment, LV_GetSelected is zero-based.

4. How do I select an item by name?

5. What other listview commands can I test? And sample syntax please, in the absence of documentation?

Thanks for all the hard work in getting us this far .. :(

Link to comment
Share on other sites

  • Administrators

This is me playing around with the new listview magic  :ph34r: :

;Wait for the folder to be activated, which is named "WWW"
;..and which has 9 shortcuts in it = listitems
    
    WinWaitActive("WWW")
    
    $hWnd = ControlGetHandle("", "", "SysListView321")
msgbox (0,"$hWnd",$hWnd)
    
    $vRet = ControlCommand("","",$hWnd, "LV_GetItemCount")
    $sRet = "" & $vRet & "::"
    $vRet = ControlCommand("","",$hWnd, "LV_GetSubItemCount")
    $sRet = $sRet & $vRet
msgbox (0,"LV_GetItemCount::LV_GetSubItemCount",$sRet)
    
    WinActivate("WWW")
    
    $vRet = ControlCommand("","",$hWnd, "LV_SelectAll")
    Sleep(2000)
    
    $vRet = ControlCommand("","",$hWnd, "LV_SelectClear")
    Sleep(2000)
    
    $vRet = ControlCommand("","",$hWnd, "LV_Select", "5", "9")
    Sleep(2000)
    
    $vRet = ControlCommand("","",$hWnd, "LV_Deselect", "2", "7")
    Sleep(2000)
    
msgbox (0,"","Select some items and i'll tell you which they are")
    $vRet = ControlCommand("","",$hWnd, "LV_GetSelected", "1")
msgbox (0,"LV_GetSelected",$vRet)

    $vRet = ControlCommand("","",$hWnd, "LV_GetItem", "1", "1")
msgbox (0,"LV_GetItem",$vRet)

Questions for Jon or anyone else who knows ..

1. I can't seem to get the LV_GetItem command to work. Any ideas?

2. How do I select items: 2,4,6 and 8 .. in one statement?

3. It would be more consistent if the LV_GetSelected referred to items in the same terms as LV_Select: At the moment, LV_GetSelected is zero-based.

4. How do I select an item by name?

5. What other listview commands can I test? And sample syntax please, in the absence of documentation?

Thanks for all the hard work in getting us this far ..  :(

Everything should be zero based so a get 0,0 will get the first item, 1,1 will select the 2nd subpart of the second item.

No way to select by name so far, I didn't know how to do arrange it for usefulness - Should I just filter by item name or filter by subparts etc.

You can't select 2,4,6 in one statement - three statements needed (i went with your simple approach)

Edited by Jon
Link to comment
Share on other sites

  • Administrators

I'm just drawing up a picture that should explain the part/subpart thing (and unless anyone knows any list controls that don't look like this it may be better to rename as items and columns)

Edited by Jon
Link to comment
Share on other sites

Everything should be zero based so a get 0,0 will get the first item, 1,1 will select the 2nd subpart of the second item.

No way to select by name so far, I didn't know how to do arrange it for usefulness -  Should I just filter by item name or filter by subparts etc.

You can't select 2,4,6 in one statement  - three statements needed (i went with your simple approach)

<{POST_SNAPBACK}>

OK .. cos LV_SelectItem is not zero-based.

I would at least like to filter / select by item .. and if you could allow subitem too, then that would be even better! Perhaps you could provide for this using the same terms as the LV_GetText command (which I guess has replaced LV_GetItem?), where: "0" means the listitem itself, and "1" is the first subitem etc. ?? Then you could default to "0"

HTH :ph34r:

edit: atrocious spelling

Edited by trids
Link to comment
Share on other sites

OK .. cos LV_SelectItem is not zero-based.

<{POST_SNAPBACK}>

Firstly, I should have said LV_Select (sorry!) .. and i see it is indeed zero-based! My bad :">

Suggestion: Maybe we could have LV_Select accept as input the result of LV_GetSelected .. ? This would allow one to store current selections, fiddle around, and then restore them back again. Also: nice and symmetrical :ph34r:

Link to comment
Share on other sites

Any chance of supporting a click on a listview's header? In Windows Explorer and many other apps, this sorts the listview, which would have a significant impact on the targeting of specific listitems.

Link to comment
Share on other sites

And (( :ph34r: )) .. Jon, while you're tinkering around with the listview API, can you also please explore the following possibilities:

  • Changing the view format (detail, list, large icon)
  • Positioning icons while in large-icon format: this is especially exciting with regard to writing an au3 script that can remember desktop layout :( (please please please)
Link to comment
Share on other sites

  • Administrators

Are list view controls always made up of just rows and columns? All the ones I've found look like that.

If so I will rename the parts/subparts thing to get Rows and Cols which might make things easier.

Link to comment
Share on other sites

Are list view controls always made up of just rows and columns? All the ones I've found look like that.

They have rows and columns .. only if the display format is set to "detail" (or "report", as it's sometimes called)

But if a listview is set to "large icon" for example, then you get the typical desktop format (which is in fact a SysListView32 control, according to Au3-spy) .. hence my request about being able to change the position of the icons :ph34r:

Link to comment
Share on other sites

  • Administrators

They have rows and columns .. only if the display format is set to "detail" (or "report", as it's sometimes called)

But if a listview is set to "large icon" for example, then you get the typical desktop format (which is in fact a SysListView32 control, according to Au3-spy)  .. hence my request about being able to change the position of the icons  :ph34r:

But that essentially works as lots of "rows" with no columns, yeah? You can still select things with the current commands?
Link to comment
Share on other sites

Quick answer: yes, i can still select items in "large icon" mode; but i'll have to play some more to see what happens to columns.

Hmm .. regardles of the display format, the item-selector number always seems to depend on the sort-order of the listview when in "detail" format. This makes sense, but would need to be carefully documented, as it may not be obvious to everyone.

Edited by trids
Link to comment
Share on other sites

Long answer:

Selecting works fine; as does GetText (see code snippet below) ... even when not in report (detail) mode. When in "large icon" mode for example, the column and row references all refer to the underlying report mode. This means that the sort order (and column) of the underlying report mode are significant when selecting by an ordinal number.

$sRet = ""
    for $nX = 0 to $nSubItems

        $vRet = ControlCommand("","",$hWnd, "LV_GetText", "1", $nX )
        $sRet = $sRet & "|" & $vRet
    next
msgbox (0,"LV_GetText",$sRet)

How do I select by item name? This doesn't work:

$vRet = ControlCommand("","",$hWnd, "LV_Select", "_ WWW.tws")

HTH :ph34r:

Link to comment
Share on other sites

Here's an interesting perspective of the dekstop: :lol:

;lets explore the desktop   

  ;wait till we click the desktop
    WinWaitActive("Program Manager")
    $hWnd = ControlGetHandle("", "", "SysListView321")
    $nItems = ControlCommand("","",$hWnd, "LV_GetItemCount")
    $nSubItems = ControlCommand("","",$hWnd, "LV_GetSubItemCount")

    FileDelete ("C:\desktop.txt")
    for $nY = 0 to $nItems
        $sLine = ""
        for $nX = 0 to $nSubItems
          ;get the subitem contents 
            $vRet = ControlCommand("","",$hWnd, "LV_GetText", $nY, $nX )
            $sLine = $sLine & "|" & $vRet
        next
        FileWriteLine("C:\desktop.txt", $sLine)
    next

  ;what did we catch?
    Run (@comspec & " /k ""C:\desktop.txt""", "", @SW_HIDE)

.. makes you think: is there a way to return the name of the subitem's column name (in the header when the view is set to detail)?

((( :ph34r: .. imagine what fun we could have if we could toggle the mode of the desktop to "report view" .. !!! :( )))

Edited by trids
Link to comment
Share on other sites

  • 4 weeks later...

thank you jon & trids. your efforts & examples made my life much easier.

now questions.. for me LV_gettext & LV_getitem return 1 not the text. what gives?

when should we expect updated documentation on the new command in the unstable build?

EDIT> i got lv_gettext working in explorer. i just have to figure out what's going on elsewhere.

Edited by dooshorama
Link to comment
Share on other sites

  • Administrators

I think I'm going to move the list view stuff into it's own command, and leave ControlCommand for the simple stuff.

ControlListView or something. I'll update the docs when I finish it and some renaming things.

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...