python pywinpyqt5应用程序的自动打印控制标识符

x33g5p2x  于 2023-01-01  发布在  Python
关注(0)|答案(1)|浏览(129)

使用python3.10,我尝试为PyQt5应用程序(例如Qt设计器)使用pywinauto和print_control_identifier。

from pywinauto.application import Application
import os

app = Application().start("C:/python/Lib/site-packages/QtDesigner/designer.exe")
main_dlg = app.QtDesigner
main_dlg.wait('visible')
main_dlg.print_control_identifiers()

输出:

Control Identifiers:

Qt5QWindowIcon - 'Qt Designer'    (L632, T250, R1928, B1008)
['Qt Designer', 'Qt DesignerQt5QWindowIcon', 'Qt5QWindowIcon']
child_window(title="Qt Designer", class_name="Qt5QWindowIcon")

奇怪的是,控件标识符可能在child_window(title ="Qt Designer",class_name ="Qt5QWindowIcon")中,但我如何访问它们呢?

5cg8jx4n

5cg8jx4n1#

from pywinauto.application import Application
import os

app = Application(backend="uia").start("C:/python/Lib/site-packages/QtDesigner/designer.exe")
main_dlg = app.QtDesigner
main_dlg.wait('visible')
main_dlg.print_control_identifiers()

backend=“uia”修复问题。如果没有相关问题,请尝试backend=“win32”

相关问题