Search code examples
pywinauto

Find children elements filter by type


I'd like to find children elements in a window but only of a certain type / class.

I use that code:

def get_visible_buttons(window):
    children = window.Children()
    return [
                child for child in children
                if child.FriendlyClassName() == 'Button'
                and child.is_visible()
           ]

Is there a best way to filter children list ? Thank you


Solution

  • It's coming in pywinauto 0.6.0 (currently in master branch).

    buttons_only = window.children(control_type='Button')
    

    The list of possible control types is to be done. The list of keyword arguments for children() is also not complete yet. See the code.