Jump to content

completed stucked on treeview


sfresher
 Share

Recommended Posts

Select tree System tools > Event viewer > Security

#include <GuiTreeView.au3>

$hTreeView = ControlGetHandle("Computer Management", "", "SysTreeView321")
$hItem = _GUICtrlTreeView_FindItemEx($hTreeView, "System Tools|Event Viewer|Security")
_GUICtrlTreeView_SelectItem($hTreeView, $hItem)
Edited by Zedna
Link to comment
Share on other sites

Thanks a lot! I am still having one question: What if the Computer Management windows has multiple treeviews? How can we get the handle for each of these treeviews? And how do we distinguish them?

#include <GuiTreeView.au3>

$hTreeView = ControlGetHandle("Computer Management", "", "SysTreeView321")
$hItem = _GUICtrlTreeView_FindItemEx($hTreeView, "System Tools|Event Viewer|Security")
_GUICtrlTreeView_SelectItem($hTreeView, $hItem)
Link to comment
Share on other sites

Thanks a lot! I am still having one question: What if the Computer Management windows has multiple treeviews? How can we get the handle for each of these treeviews? And how do we distinguish them?

You can examine them with AU3Info.exe to see what their CLASS and INSTANCE are, which combine to form ClassNameNN, i.e. "[CLASS:SysTreeView32; INSTANCE:1]" and "[CLASS:SysTreeView32; INSTANCE:2]" become "SysTreeView321" and "SysTreeView322".

There are more ways to specify a control. Look in the help file index at "Controls".

:)

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

A new problem pops up: What if the tree item may dynamically change their name? Can I use a wildcard selection to select the tree item?

For example, System Tools > Event Viewer[%] > Security, where % maybe 01, 02, 03.

#include <GuiTreeView.au3>

$hTreeView = ControlGetHandle("Computer Management", "", "SysTreeView321")
$hItem = _GUICtrlTreeView_FindItemEx($hTreeView, "System Tools|Event Viewer|Security")
_GUICtrlTreeView_SelectItem($hTreeView, $hItem)
Link to comment
Share on other sites

A new problem pops up: What if the tree item may dynamically change their name? Can I use a wildcard selection to select the tree item?

For example, System Tools > Event Viewer[%] > Security, where % maybe 01, 02, 03.

It's not a name, it's just text in the item. A TreeView item is referenced by index number and handle with the UDF functions and by a funky formatted string in the native ControlTreeView() functions. The code posted uses the UDF functions, which includes things like _GUICtrlTreeView_FindItem(). See the example posted there in the help file.

It does not allow wildcards. So you would have to code a recursive search using things like _GUICtrlTreeView_GetChildCount(), _GUICtrlTreeView_GetFirstChild(), _GUICtrlTreeView_GetNextChild(), _GUICtrlTreeView_GetText().

:)

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

Thanks a lot, PsaltyDS. You have answered quite a few numbers of my questions and kind of enlightened my programming experience with AutoIt.

It's not a name, it's just text in the item. A TreeView item is referenced by index number and handle with the UDF functions and by a funky formatted string in the native ControlTreeView() functions. The code posted uses the UDF functions, which includes things like _GUICtrlTreeView_FindItem(). See the example posted there in the help file.

It does not allow wildcards. So you would have to code a recursive search using things like _GUICtrlTreeView_GetChildCount(), _GUICtrlTreeView_GetFirstChild(), _GUICtrlTreeView_GetNextChild(), _GUICtrlTreeView_GetText().

:)

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