Sign in to follow this  
Followers 0
deadshot

TreeView - How to get root and items?

5 posts in this topic

Hi, All.

Please help me fix my issue with SysTreeView.

I have an window with system treeView control (SysTreeView32), it is not control which was created by AutoIt. How can I get items from this treeView, navigate through items, list them?

I know only HWND, className and text of this control:

$hSysTreeView32 = ControlGetHandle("Options", "Tree1", "SysTreeView321")

Share this post


Link to post
Share on other sites



Hmm... Can i use

GUICtrlSendMsg($hSysTreeView32, "TVM_GETCOUNT", 0, 0)
functions in this case?

Should second parameter be a number or string in this case?

Share this post


Link to post
Share on other sites

Look at Auto3Library:

There are nice examples : "Examples\treeview 2.au3"

#include <A3LMenu.au3>
#include <A3LTreeView.au3>

Opt("MustDeclareVars", 1)

; =================================================================================================
; Description ...: TreeView demo script
; Author ........: Paul Campbell (PaulIA)
; Notes .........: This script MUST be run from the SciTE editor in order to see the results
; =================================================================================================

; =================================================================================================
; Global variables
; =================================================================================================

Global $hTree

; =================================================================================================
; Main
; =================================================================================================

Run("c:\windows\explorer.exe")
_Lib_WinWaitActive("My Documents")
$hTree = ControlGetHandle("My Documents", "", "SysTreeView321")
if @Error then _Lib_ShowError("Unable to find TreeView window")

; =================================================================================================
; Tests
; =================================================================================================

OpenFolder()
ShowTree()
ShowNodes()

; =================================================================================================
; Open "My Computer" folder
; =================================================================================================
Func OpenFolder()
  Local $hNode

  $hNode = _TreeView_FindNode($hTree, "My Computer")
  if $hNode = 0 then _Lib_ShowError('Unable to find "My Computer" folder')
  _TreeView_Click($hTree, $hNode)
EndFunc

; =================================================================================================
; Show TreeView details
; =================================================================================================
Func ShowTree()
  Local $hRoot

  $hRoot = _TreeView_GetFirstNode($hTree)
  _Lib_ConsoleWrite("Tree First Node ........: " & $hRoot                              )
  _Lib_ConsoleWrite("Tree First Visible .....: " & _TreeView_GetFirstVisible   ($hTree))
  _Lib_ConsoleWrite("Tree Handle ............: " & $hTree                              )
  _Lib_ConsoleWrite("Tree Image List Normal .: " & _TreeView_GetNormalImageList($hTree))
  _Lib_ConsoleWrite("Tree Image List State ..: " & _TreeView_GetStateImageList ($hTree))
  _Lib_ConsoleWrite("Tree Indent ............: " & _TreeView_GetIndent         ($hTree))
  _Lib_ConsoleWrite("Tree Max Visible Count .: " & _TreeView_GetVisibleCount   ($hTree))
  _Lib_ConsoleWrite("Tree Node Count ........: " & _TreeView_GetCount          ($hTree))
  _Lib_ConsoleWrite("Tree Node Height .......: " & _TreeView_GetHeight         ($hTree))
  _Lib_ConsoleWrite("Tree Scroll Time .......: " & _TreeView_GetScrollTime     ($hTree))
  _Lib_ConsoleWrite("Tree Selection .........: " & _TreeView_GetSelection      ($hTree))
  _Lib_ConsoleWrite("Tree ToolTip Handle ....: " & _TreeView_GetToolTips       ($hTree))
  _Lib_ConsoleWrite("Tree Unicode Format ....: " & _TreeView_GetUnicodeFormat  ($hTree))
  _Lib_ConsoleWrite()
EndFunc

; =================================================================================================
; Show TreeView node details
; =================================================================================================
Func ShowNodes()
  Local $iX1, $iY1, $iX2, $iY2, $hNext, $aRect

  $hNext = _TreeView_GetFirstNode($hTree)
  while $hNext <> 0
    $aRect = _TreeView_DisplayRect($hTree, $hNext, True)

    _Lib_ConsoleWrite("Node ...................: " & $hNext                                    )
    _Lib_ConsoleWrite("Node Accessibility ID ..: " & _TreeView_MapNodeToAccID  ($hTree, $hNext))
    _Lib_ConsoleWrite("Node Child Count .......: " & _TreeView_GetCount        ($hTree, $hNext))
    _Lib_ConsoleWrite("Node First Child .......: " & _TreeView_GetFirstChild   ($hTree, $hNext))
    _Lib_ConsoleWrite("Node Has Children ......: " & _TreeView_GetChildren     ($hTree, $hNext))
    _Lib_ConsoleWrite("Node Image Index .......: " & _TreeView_GetImageIndex   ($hTree, $hNext))
    _Lib_ConsoleWrite("Node Index .............: " & _TreeView_Index           ($hTree, $hNext))
    _Lib_ConsoleWrite("Node Is Bold ...........: " & _TreeView_GetBold         ($hTree, $hNext))
    _Lib_ConsoleWrite("Node Is Cut ............: " & _TreeView_GetCut          ($hTree, $hNext))
    _Lib_ConsoleWrite("Node Is Drop Target ....: " & _TreeView_GetDropTarget   ($hTree, $hNext))
    _Lib_ConsoleWrite("Node Is Expanded .......: " & _TreeView_GetExpanded     ($hTree, $hNext))
    _Lib_ConsoleWrite("Node Is Expanded Once ..: " & _TreeView_ExpandedOnce    ($hTree, $hNext))
    _Lib_ConsoleWrite("Node Is Focused ........: " & _TreeView_GetFocused      ($hTree, $hNext))
    _Lib_ConsoleWrite("Node Is Selected .......: " & _TreeView_GetSelected     ($hTree, $hNext))
    _Lib_ConsoleWrite("Node Is Visible ........: " & _TreeView_GetVisible      ($hTree, $hNext))
    _Lib_ConsoleWrite("Node Last Child ........: " & _TreeView_GetLastChild    ($hTree, $hNext))
    _Lib_ConsoleWrite("Node Level .............: " & _TreeView_Level           ($hTree, $hNext))
    _Lib_ConsoleWrite("Node Next Visible ......: " & _TreeView_GetNextVisible  ($hTree, $hNext))
    _Lib_ConsoleWrite("Node Overlay Index .....: " & _TreeView_GetOverlayIndex ($hTree, $hNext))
    _Lib_ConsoleWrite("Node Parent ............: " & _TreeView_Parent          ($hTree, $hNext))
    _Lib_ConsoleWrite("Node Prev Child ........: " & _TreeView_GetPrevChild    ($hTree, $hNext))
    _Lib_ConsoleWrite("Node Previous ..........: " & _TreeView_GetPrev         ($hTree, $hNext))
    _Lib_ConsoleWrite("Node Prev Visible ......: " & _TreeView_GetPrevVisible  ($hTree, $hNext))
    _Lib_ConsoleWrite("Node Rectangle .........: [" & $aRect[1] & ", " & $aRect[2] & ", " & $aRect[3] & ", " & $aRect[4] & "]" )
    _Lib_ConsoleWrite("Node Selected Index ....: " & _TreeView_GetSelectedIndex($hTree, $hNext))
    _Lib_ConsoleWrite("Node State Index .......: " & _TreeView_GetStateIndex   ($hTree, $hNext))
    _Lib_ConsoleWrite("Node Text ..............: " & _TreeView_GetText         ($hTree, $hNext))
    _Lib_ConsoleWrite()
    $hNext = _TreeView_GetNext($hTree, $hNext)
  wend
EndFunc

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