问题
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