按类型查找子元素过滤器

Find children elements filter by type

我想在 window 中查找子元素,但仅限于某种类型 / class.

我使用那个代码:

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

是否有过滤子列表的最佳方法? 谢谢

它将在 pywinauto 0.6.0 中出现(目前在 master 分支中)。

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

可能的控件类型列表待完成。 children() 的关键字参数列表也不完整。参见 the code