Function Reference

ControlSysTreeView


Sends a command to a SysTreeView32 control (similar to ControlTreeView).

#include <r_SysTreeView.au3>
ControlSysTreeView ( "title", "text", controlID, "command" [, option1 [, option2]] )

Parameters

title The title of the window to access.
text The text of the window to access.
controlID The control to interact with. See Controls.
command The command to send to the control (see below).
option1 Additional parameter (usually "item") required by most commands, but optional in GetSelected.
option2 Additional parameter, required for SetRadio, optional for WhichRadio.


Commands, Options and Return Value

Command, Option1, Option2 Operation
"Check", "item" Checks a check-box (it CAN be used to set a radio-button, though "SetRadio" would usually be neater).
Returns True/False for success, or -1 for an error.
Note that this *may* change the value of "Selected". Be careful if your code relies on the value of "Selected" before/after this command.
"Collapse", "item" Collapses an item to hide its children.
"Exists", "item" Returns True if an item exists, False if not.
"Expand", "item" Expands an item to show its children.
"GetItemCount", "item" Returns the number of children for a selected item.
Failure (eg. item doesn't exist) returns -1 and sets @error to 1.
"GetSelected" [, UseIndex] If UseIndex is not specified, returns the text-form item-reference of the currently selected item.
If UseIndex is 1, returns the item-reference of the currently selected item in numeric form eg. "#0|#1".
"GetText", "item" Returns the text of an item.
"IsCheckBox", "item" Returns True/False that the specified item is a check-box, or -1 for an error (eg. not found).
See also "IsRadioButton", "IsRadioGroup".
"IsChecked", "item" Returns True/False that a check-box is checked.
Failure returns -1 and sets @error to 1.
(Can be used to interrogate a radio-button, though usually "WhichRadio" would be better.)
"IsRadioButton", "item" Returns True/False that the specified item is a radio-button, or -1 for an error (eg. not found).
See also "IsCheckBox", "IsRadioGroup".
"IsRadioGroup", "item" Returns True/False that the specified item is (the heading for) a radio-group, or -1 for an error (eg. not found).
See also "IsCheckBox", "IsRadioButton".
"Select", "item" Selects an item (eg. to then use "GetSelected".
"SetRadio", "item", "button-identifier" Sets (pushes or checks) the specified radio-button in the named radio-group.
The button-identifier is either the text on the radio-button, or its 0-based index-number.
Failure returns -1 and sets @error to 1.
Note that this *may* change the value of "Selected". Be careful if your code relies on the value of "Selected" before/after this command.
"WhichRadio", "item" [, AsIndex] Allows you to determine which radio-button of "item" radio-group is checked/set.
If AsIndex is not specified, or False, the result is the text on the radio-button.
If AsIndex is True, the result is the (0-based) index-number of the radio-button within the radio-group, eg. 0 or 1
Failure returns -1 and sets @error to 1.
"Uncheck", "item" Unchecks a check-box item (NOT a radio-button - you can't un-check a radio-button!).
Returns True/False for success, or -1 for an error.
Note that this *may* change the value of "Selected". Be careful if your code relies on the value of "Selected" before/after this command.
In case of an error (such as an invalid command or the window/control could not be found) then ControlSysTreeView returns -1 and @error is set to 1.

The "item" parameter is a string that is used to identify a particular treeview item using a combination of text (labels) and/or (0-based) indices.


Remarks

As AutoIt is a 32-bit application some commands are not available when referencing a 64-bit application as Explorer when running on 64-bit Windows.


Related

ControlCommand, ControlDisable, ControlEnable, ControlFocus, ControlGetPos, ControlGetText, ControlHide, ControlClick, ControlListView, ControlMove, ControlSetText, ControlShow, ControlTreeView, StatusbarGetText, TreeViewItem, WinMenuSelectItem, WinGetClassList


Example

; Author: RAC
#include <r_SysTreeView.au3>

;<--- code to navigate to StartMenu Properties, Advanced --->

Const $OUR_WINDOW = "[TITLE:Customize Start Menu]"
Const $OUR_TREEVIEW = "[CLASS:SysTreeView32; ID:1123]"

;find out the setting for Control Panel
$iWhichCtlPanelOption = ControlSysTreeView($OUR_WINDOW, "", $OUR_TREEVIEW, "WhichRadio", "Control Panel")

;find out if they've enabled dragging and dropping
$bDragAndDropEnabled = ControlSysTreeView($OUR_WINDOW, "", $OUR_TREEVIEW, "IsChecked", "#1")

;enable the Favourites menu
ControlSysTreeView($OUR_WINDOW, "", $OUR_TREEVIEW, "Check", "#2")

;don't display My Computer
ControlSysTreeView($OUR_WINDOW, "", $OUR_TREEVIEW, "SetRadio", "My Computer", 2)