Sends a command to a TreeView32 control.
ControlTreeView ( "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 | [optional] Additional parameter required by some commands. |
| option2 | [optional] Additional parameter required by some commands. |
Return Value
Depends on command as table below shows. In case of an error (such as an invalid command or window/control could not be found) then @error is set to 1.| Command, Option1, Option2 | Operation |
| "Check", "item" | Checks an item (if the item supports it). |
| "Collapse", "item" | Collapses an item to hide its children. |
| "Exists", "item" | Returns 1 if an item exists, otherwise 0. |
| "Expand", "item" | Expands an item to show its children. |
| "GetItemCount", "item" | Returns the number of children for a selected item. |
| "GetSelected" [, UseIndex] | Returns the item reference of the current selection using the text reference of the item (or index reference if UseIndex is set to 1). |
| "GetText", "item" | Returns the text of an item. |
| "IsChecked" | Returns the state of an item. 1:checked, 0:unchecked, -1:not a checkbox. |
| "Select", "item" | Selects an item. |
| "Uncheck", "item" | Unchecks an item (if the item supports it). |
| Item | Item Reference |
| Heading2 | "Heading2" or "#1" |
| H1SubItem2 | "Heading1|H1SubItem2" or "#0|#1" |
| H1S1SubItem1 | "Heading1|H1SubItem3|H1S1SubItem1" or "#0|#2|#0" |
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, StatusbarGetText, WinMenuSelectItem, WinGetClassList
Example
; Author: Zedna
#include <GUIConstantsEx.au3>
#include <TreeviewConstants.au3>
#include <WindowsConstants.au3>
$gui = GUICreate("ControlTreeview test", 212, 212)
$treeview = GUICtrlCreateTreeView(6, 6, 200, 160, BitOR($TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_CHECKBOXES), $WS_EX_CLIENTEDGE)
$h_tree = ControlGetHandle($gui, "", $treeview)
$root = GUICtrlCreateTreeViewItem("Root", $treeview)
$item1 = GUICtrlCreateTreeViewItem("Item 1", $root)
$item2 = GUICtrlCreateTreeViewItem("Item 2", $root)
$item3 = GUICtrlCreateTreeViewItem("Item 3", $root)
$item4 = GUICtrlCreateTreeViewItem("Item 4", $root)
$item41 = GUICtrlCreateTreeViewItem("Item 41", $item4)
$item42 = GUICtrlCreateTreeViewItem("Item 42", $item4)
$item5 = GUICtrlCreateTreeViewItem("Item 5", $root)
GUISetState(@SW_SHOW)
; some examples
ControlTreeView ($gui, "", $h_tree, "Expand", "Root")
ControlTreeView ($gui, "", $h_tree, "Exists", "Root|Item 4")
ControlTreeView ($gui, "", $h_tree, "Check", "Root|Item 4")
ControlTreeView ($gui, "", $h_tree, "Select", "Root|Item 4")
ControlTreeView ($gui, "", $h_tree, "Expand", "Root|Item 4")
While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE
ExitLoop
EndSelect
WEnd