Jump to content

Recommended Posts

Posted

Hi,

I am trying to select items with "Win" in its name. However, How about if it has to search texts with "History" AND "Win" at the same time?

Thanks

_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
Posted

You have to do two searches at the same time, and compare the indexes using _GUICtrlTreeView_Index. You use the item with the lower index as $hItemFound. In pseudo code:

While foundItem
    Select(foundItem)
    nextItem = GetNextVisible()

    foundWinItem = FindItem("Win")
    foundHistoryItem = FindItem("History")

    If Index(foundWinItem) < Index(foundHistoryItem) Then
        foundItem = foundWinItem
    Else
        foundItem = foundHistoryItem
    EndIf
WEnd
Posted (edited)
While foundItem
    Select(foundItem)
    nextItem = GetNextVisible()

    foundWinItem = FindItem("Win")
    foundHistoryItem = FindItem("History")

    If Index(foundWinItem) < Index(foundHistoryItem) Then
        foundItem = foundWinItem
    Else
        foundItem = foundHistoryItem
    EndIf
WEnd

This works somehow, but it skips other items with win or history though.

Edited by bazinguuh

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...