How to search children/descendants by regular expression title in pywinauto?

跟風遠走 提交于 2019-12-13 01:50:49

问题


I am trying to get children/descendant UI elements of another UI element by a regexp title.

For example, the following code should work.

from pywinauto.application import Application, WindowSpecification
root_ws: WindowSpecification = (
    Application(backend="uia")
        .connect(path="C:/program.exe")
        .window(title_re="^Program *")
)
root_ws.descendants(title_re="^abc*", control_type="DataItem")

However, as described (by Vasily Ryabov) in this comment, title_re is not possible for children/descendants.

The function that supports search of children by a regular expression is find_elements, however it doesn't accept root_ws as parent:

import pywinauto
pywinauto.findwindows.find_elements(title_re="^abc*", 
                                    top_level_only=False,
                                    parent=root_ws)

throws an exception AttributeError: 'StaticWrapper' object has no attribute 'rich_text'

How could I find a child of another UI element by only having a regexp title?

来源:https://stackoverflow.com/questions/56873733/how-to-search-children-descendants-by-regular-expression-title-in-pywinauto

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!