搜索树并选择项目 [英] Search tree and select items

查看:61
本文介绍了搜索树并选择项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您知道如何扫描树并选择项目.例如,autoit帮助文件.我将所有树展开,接下来要做的就是扫描名称中带有历史记录"的项目.如果为true,则必须选择它并休眠5秒钟,然后继续选择找到的下一个项目,直到结束循环.

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)

推荐答案

就这么简单:

#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仍将搜索折叠的项目.

By the way, you can use _GUICtrlTreeView_GetNext(...) instead for not only searching the visible next entry but the probably collapsed one as well. The ..._FindItem will search for collapsed Items anyways.

除了_GUICtrlTreeView_SelectItem(...)之外,您可能还想使用_GUICtrlTreeView_ClickItem(...)来获得对选定内容执行的正确操作.

And you'd probably want to use _GUICtrlTreeView_ClickItem(...) in addition to _GUICtrlTreeView_SelectItem(...) to get the proper action performed with a selection as well.

这篇关于搜索树并选择项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆