所以我在窗口中使用get_focus()
函数从包装器中获取此信息:
{'class_name': 'Edit', 'friendly_class_name': 'Edit', 'texts': ['', ''], 'control_id': 232, 'rectangle': <RECT L251, T523, R485, B545>, 'is_visible': True, 'is_enabled': True, 'control_count': 0, 'style': 1342242944, 'exstyle': 516, 'user_data': 0, 'context_help_id': 0, 'fonts': [<LOGFONTW 'Arial' -13>], 'client_rects': [<RECT L0, T0, R230, B18>], 'is_unicode': False, 'menu_items': [], 'automation_id': '', 'selection_indices': (0, 0)}
我知道它与 WindowSpecification 相同(通过使用control_identifiers()
然后wrapper_object()
函数发现):
Edit - '' (L251, T523, R485, B545)
['Edit2', 'TunnusEdit']
child_window(class_name="Edit")
如您所见,包装器没有名称TunnusEdit
。我可以从包装器中获取此信息吗?
不,你现在必须创建多级 WindowSpecification。我们计划在将来的版本中添加此功能。但不能保证它会很快。请参阅问题 #570。
EDIT1:如果您使用的是"win32"后端(默认为Application()
),它仅支持 2 个级别的 WindowSpecification:第一个用于顶级窗口,第二个用于任何后代。所以像app.MainWindowTitle.TunnusEdit.wrapper_object()
这样的东西会有所帮助。