PyWinAuto: How to get the index of an active tree item from win32 application

So for example lets say I had a tree with three nodes and I wanted to return the index of the second node. Then it should print 1 because 1 is the index for the second node. In the documentation for the uia wrapper https://pywinauto.readthedocs.io/en/uia/code/pywinauto.controls.uiawrapper.html it says the function selected_item_index() return the index of a selected item" for the class pywinauto.controls.uiawrapper.UIAWrapper. I tested this out with a basic uia ListView application and wrote something like app.ListBox.selected_item_index() that was able to retrieve the index for me. However this will not work with my TreeView in my win32 application since the wrapper method obviously doesn’t exist outside of the UIAwrapper(unless I’m blind). So I looked over the documentation https://pywinauto.readthedocs.io/en/uia/code/pywinauto.controls.win32_controls.html and they did mention some index functions for the Combox and Listbox wrapper but not for TreeView. Now I’m wondering if such a function even exists. Maybe I overlooked a documentation somewhere that explains it but this has me running in circles at this point.

Add Comment
0 Answer(s)

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.