Jump to content
Sign in to follow this  
jdegraff

How do I get at text items in a TreeView

Recommended Posts

I'm trying to get the names if the items in a TreeView control. I have the control ID (200864) and I can get the item count but I can't get at the actual items. The best I've been able to manage is to get the item reference. As you can see I am able to determine that items #0 through #3 exist. But when I try to get the text I get nothing. Similarly, when I select an item and try to fetch it I get only the item reference. How can I get at the actual text items? Screen snaps are attached.2019-09-01_113526.thumb.jpg.0df820fcad97ac2963d304b31e4f6f6f.jpg

Code
====

    import os
    import win32com.client

    aut_MatchFromStart = 1

    id  = 200864
    win = "Batch"

    aut = win32com.client.Dispatch("AutoItX3.Control")
    aut.Opt("WinTitleMatchMode", aut_MatchFromStart)

    print("ItemCount=",aut.ControlTreeView(win,"",id,"GetItemCount","",""))

    for i in range(0,5):
        item = "#" + str(i)
        print("item",i,"exists=",aut.ControlTreeView(win,"",id,"Exists",item,""))

    print("GetText #0 = <%s>" % aut.ControlTreeView(win,"",id,"GetText","#0",""))
    print("Select result=",aut.ControlTreeView(win,"",id,"Select",0,""))
    print("GetSelected= <%s>" % aut.ControlTreeView(win,"",id,"GetSelected",0,""))
    print("GetSelected= <%s>" % aut.ControlTreeView(win,"",id,"GetSelected",0,1))

Output
======

    ItemCount= 4
    item 0 exists= 1
    item 1 exists= 1
    item 2 exists= 1
    item 3 exists= 1
    item 4 exists= 0
    GetText #0 = <>
    Select result= 1
    GetSelected= <#0>
    GetSelected= <#0>

2019-09-01_113547.jpg

Edited by jdegraff
typo

Share this post


Link to post
Share on other sites

How is this thread different from 

Which you posted more than a year ago?
Does that mean you never solved it and though: "let's try again"?

Jos

EDIT: ... and I see you also reported your own thread to delete it ....  sweet, wel we don't delete threads unless they are in violation of some rules, so 
*click*

Edited by Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...