Jump to content
Sign in to follow this  

Selecting a tree Item

Recommended Posts


I have a WPF application with a  treeview control that contains an item (stringXYZ) in several/different branches; however, the second instance is the one I am looking for.  The following code finds it for me.

 $searchText = "StringXYZ"

$hItemFound = _GUICtrlTreeView_FindItem($hWnd, $searchText, True)

 $J=0 ;

  While $hItemFound

   if $J < 2 THEN ;find the second instance of StringXYZ

    _GUICtrlTreeView_SelectItem($hWnd, $hItemFound)

$next = _GUICtrlTreeView_GetNextVisible($hWnd, $hItemFound)

$hItemFound = _GUICtrlTreeView_FindItem($hWnd, $searchText, True, $next)




   ;found the string




Now that I found it, I need to select it even though it appears to be already selected by the slightly gray background.  Also the function  

   _GUICtrlTreeView_SelectItem($hWnd, $hItemFound) returns TRUE meaning it is selected

However, when I manually click on the stringXYZ, I can clearly see that it is selected for sure (Darker blue background).

The application does not take any shortcuts, tabs or any keyboard combination until I manually click on the stringXYZ item.  I cannot find any key combination that allows me to select it

So I am struggling to find the way to automate.

The mouseclick(“left”)-does not work

Send (“{TAB}”)-does not work

May be the only way is to call it by its handler but problem is the handle changes every time the application is restarted.

Any suggestions is greatly appreciated.

Share this post

Link to post
Share on other sites

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
Sign in to follow this