accessing ListViewItem via pwinauto

Viewed 638

pywinauto recognized my GUI object as listview. The gui object is a grid with checkboxes in each cell. I am trying to click a certain checkbox via a ListView.items()[index], item operation. (all the items, checkboxes, are recognized and reside under ListView.items()).

The problem is that some of the items aren't responding to clicks. For example: the following code only clicks successfully on 60% of the items.

I have tried to click in any other possible way, using click,select,check and using the double=True flag via click.

for item in self.curr_win.ListView5.items():
    item.click()

*self.curr_win.ListView5 is my list view object

  • I need a way to control all the checkboxes, I would appreciate any help!
  • A picture of the GUI object is below

enter image description here

1 Answers

OK, for "win32" backend you can use these docs for ListViewWrapper and _listview_item objects: https://pywinauto.readthedocs.io/en/latest/code/pywinauto.controls.common_controls.html#pywinauto.controls.common_controls._listview_item

for item in self.curr_win.ListView5.items():
    item.click(where="check")
    # or
    # item.click_input(where="check")

Item method .ensure_visible() makes automatic scrolling for invisible items.

The difference in method .click_input() is that it moves real mouse cursor that can make all the actions more visible while debugging.

Related