我在这里有一个代码,可以搜索并选择名称中带有“Win”的项目。但我必须修改它以搜索名称中包含“Win”、“History”、“Credits”或“#”的项目并选择它。谢谢!
_GUICtrlTreeView_Expand(ControlGetHandle("[CLASS:HH Parent;TITLE:AutoIt Help]","", "[CLASS:SysTreeView32; INSTANCE:1]"),0, True)
Global $hWnd = ControlGetHandle("[CLASS:HH Parent;TITLE:AutoIt Help]", "", "[CLASS:SysTreeView32; INSTANCE:1]")
$searchText = "Win"
$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(1000)
WEnd
我也尝试使用switch
但不起作用:
Global $hWnd = ControlGetHandle("[CLASS:HH Parent;TITLE:AutoIt Help]", "", "[CLASS:SysTreeView32; INSTANCE:1]")
$searchText = "Autoit"
$hItemFound = _GUICtrlTreeView_FindItem($hWnd, $searchText, True)
While $hItemFound
_GUICtrlTreeView_SelectItem($hWnd, $hItemFound)
$next = _GUICtrlTreeView_GetNextVisible($hWnd, $hItemFound)
$foundWinItem = _GUICtrlTreeView_FindItem($hWnd, "Win", True,$next)
$foundHistoryItem = _GUICtrlTreeView_FindItem($hWnd, "History", True,$next)
Switch $next
Case "Win"
$hItemFound = $foundWinItem
Case "History"
$hItemFound = $foundHistoryItem
EndSwitch
WEnd