0

Do you know how to scan a tree and select an item. For example is the autoit help file. I expand all the tree and what it has to do next is scan the items with a "history" in its name. If true, it has to select it and sleep for 5 seconds and continue select the next item it finds until end loop.

Global $hWnd = ControlGetHandle("[CLASS:HH Parent;TITLE:AutoIt Help]", "", "[CLASS:SysTreeView32; INSTANCE:1]")

$hItemFound = _GUICtrlTreeView_FindItem($hWnd, "History",True)

_GUICtrlTreeView_SelectItem($hWnd, $hItemFound)
4

1 回答 1

0

就这么简单:

#include <GuiTreeView.au3>

Global $hWnd = ControlGetHandle("[CLASS:HH Parent;TITLE:AutoIt Help]", _
                                "", "[CLASS:SysTreeView32; INSTANCE:1]")

$searchText = "History"
$hItemFound = _GUICtrlTreeView_FindItem($hWnd, $searchText, True)
While $hItemFound
   _GUICtrlTreeView_SelectItem($hWnd, $hItemFound)
   $next = _GUICtrlTreeView_GetNextVisible($hWnd, $hItemFound)
   $hItemFound = _GUICtrlTreeView_FindItem($hWnd, $searchText, True, $next)
   Sleep(5000)
WEnd

顺便说一句,您_GUICtrlTreeView_GetNext(...)不仅可以使用它来搜索可见的下一个条目,还可以用于搜索可能折叠的条目。..._FindItem无论如何都会搜索折叠的项目。

并且您可能还想使用_GUICtrlTreeView_ClickItem(...)除了来_GUICtrlTreeView_SelectItem(...)获得通过选择执行的正确操作。

于 2013-06-17T13:41:50.947 回答