Sign in to follow this  
Followers 0
dazza

TreeView - a simply thing (but not for me)

5 posts in this topic

How do I get the path/text of each item in a treeview

GetTree? GetNext?

I have blundered about finding no examples that match :¬(

Please put me out of my misery

$treeview = ControlGetHandle("window name", "", "[CLASS:SysTreeView32]")

Share this post


Link to post
Share on other sites



How do I get the path/text of each item in a treeview

GetTree? GetNext?

I have blundered about finding no examples that match :¬(

Please put me out of my misery $treeview = ControlGetHandle("window name", "", "[CLASS:SysTreeView32]")

Look in the help file at ControlTreeView(), and the many _GuiCtrlTreeView_* functions of the GuiTreeView.au3 UDF.

:)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

Look in the help file at ControlTreeView(), and the many _GuiCtrlTreeView_* functions of the GuiTreeView.au3 UDF.

:)

I did for an hour, and I couldn't fine one example of looping through a treeview outputting the item path/name :party:

Share this post


Link to post
Share on other sites

I did for an hour, and I couldn't fine one example of looping through a treeview outputting the item path/name :idea:

It's similar to recursive search of directory trees. You have to code them. List the parent items, check each one for child items, recurse through the children looking for more child items, etc.

I'm sympathetic about the difficulty of the TreeView32 API. It is a pain in the butt to work with in the _GuiCtrlTreeView_* functions because what seem like obvious functions appear to be missing. And there is an awkward switch between referring to items by handles or indexes, depending on the function. It's not an object interface so nothing can return a collection of child items or an array of item handles, for instance. AutoIt didn't do that. Microsoft's DLLs did, and AutoIt has to use them. (If you need your mind bent for the day, crack open GuiTreeView.au3 in SciTE and read the MSDN articles on some of those DLL calls.) :party:

When I get some free time, I could code a short demo, but it has probably been done in the past. Don't give up on the forum search function.

:)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

It's similar to recursive search of directory trees. You have to code them. List the parent items, check each one for child items, recurse through the children looking for more child items, etc.

I'm sympathetic about the difficulty of the TreeView32 API. It is a pain in the butt to work with in the _GuiCtrlTreeView_* functions because what seem like obvious functions appear to be missing. And there is an awkward switch between referring to items by handles or indexes, depending on the function. It's not an object interface so nothing can return a collection of child items or an array of item handles, for instance. AutoIt didn't do that. Microsoft's DLLs did, and AutoIt has to use them. (If you need your mind bent for the day, crack open GuiTreeView.au3 in SciTE and read the MSDN articles on some of those DLL calls.) :party:

When I get some free time, I could code a short demo, but it has probably been done in the past. Don't give up on the forum search function.

:)

This works (after much experimentation)

$treeview = ControlGetHandle("Win Name", "", "[CLASS:SysTreeView32]")
$item = _GUICtrlTreeView_GetSelection($treeview)
$item = _GUICtrlTreeView_GetNext($treeview, $item)
$finish = _GUICtrlTreeView_GetCount($treeview)

While 1
      $count = $count + 1
      $text = _GUICtrlTreeView_GetTree($treeview, $item)  ;$text holds parent|item name
      If $count = $finish then ExitLoop
    
      $item = _GUICtrlTreeView_GetNext($treeview, $item)
    
WEnd
Edited by dazza

Share this post


Link to post
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
Sign in to follow this  
Followers 0