Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Find children elements filter by type

Tags:

pywinauto

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

like image 314
Sebastien RAGONS Avatar asked Oct 23 '25 10:10

Sebastien RAGONS


1 Answers

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.

like image 130
Vasily Ryabov Avatar answered Oct 26 '25 14:10

Vasily Ryabov