我正在尝试自动化windows gui鼠标点击打印机属性中的复选框。
通过启动打印管理mmc,右键单击左窗格中的“打印服务器”下拉列表中的“G23XnQ2E(本地)”,然后选择“属性”,切换到“安全选项卡”,最后我想选中“管理打印机”选项的复选框。如果我已经从打印机服务器中选择了“G23XnQ2E(local)”,也可以通过直接单击“操作”菜单并选择“属性”来实现。在
我已经尝试了所有可能的方法,但最终总是会出现许多错误,比如“raise AttributeError”、“menu\u select”、“select()”、“click()”—“missing”。在
我的代码是这样的:
from pywinauto import Application
Application().start(r'mmc printmanagement.msc')
app = Application(backend="uia").connect(path='mmc.exe')
app.PrintManagement.dump_tree()
app.dialog.pane1.pane5.pane6.menu.menu_select("Action -> Properties")
#app.dialog.menu_select("Action -> Properties")
#app.dialog.pane1.pane5.pane6.menu.ActionMentuitem.select()
#app.dialog.pane1.pane5.pane6.menu.ActionMentuitem.click()
如何解决这个问题?在
menu_select
适用于主菜单,如“文件->打开”。它不适用于弹出菜单/上下文菜单。这是我在我的电脑上工作的代码(打印服务器的名称已更改为您的名称):所有
child_window
规范已从dump_tree()
输出复制。有些窗口是主窗口的子窗口,但上下文菜单是顶级窗口。这不是一个记录在案的经验,但我们正在开发一个录音功能,计划今年作为测试版。因此,在不考虑太多层次结构的情况下生成脚本将更加容易。在相关问题 更多 >
编程相关推荐