pywinauto - 如何在pywinauto中连接到control.exe的子窗口
问题描述
我可以通过下面的代码打开控制面板,也可以获取所有控制面板项的 dump_tree。我的意图是在一次控制面板下面。当我尝试单击网络和共享中心时出现以下错误。有人可以帮忙吗
我的意图: - 在网络和共享中心的左侧面板中,打开更改高级共享设置 - 在网络发现下,单击“关闭网络发现”选项。-单击“保存更改”-转到工具->文件夹选项->查看。-勾选‘隐藏受保护的操作系统文件 -关闭保存
我的代码:
Application().start(r'control.exe', wait_for_idle=False)
app = Application(backend="uia").connect(title="All Control Panel Items", timeout=10)
main_window = app.window(title="All Control Panel Items")
#main_window.dump_tree()
Network=main_window.child_window(title="Network and Sharing Center", control_type="Hyperlink").select()
Network.select() # it expands the subtree
获取错误:
Traceback (most recent call last):
File "C:\Users\sandy\AppData\Local\Programs\Python\Python36-32\lib\site-packages\pywinauto\uia_defines.py", line 234, in get_elem_interface
iface = cur_ptrn.QueryInterface(cls_name)
File "C:\Users\sandy\AppData\Local\Programs\Python\Python36-32\lib\site-packages\comtypes\__init__.py", line 1158, in QueryInterface
self.__com_QueryInterface(byref(iid), byref(p))
ValueError: NULL COM pointer access
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\sandy\AppData\Local\Programs\Python\Python36-32\My_Test\Step_46.py", line 16, in <module>
step_34()
File "C:\Users\sandy\AppData\Local\Programs\Python\Python36-32\My_Test\Step_46.py", line 11, in step_34
Network=main_window.child_window(title="Network and Sharing Center", control_type="Hyperlink").select()
File "C:\Users\sandy\AppData\Local\Programs\Python\Python36-32\lib\site-packages\pywinauto\controls\uiawrapper.py", line 605, in select
self.iface_selection_item.Select()
File "C:\Users\sandy\AppData\Local\Programs\Python\Python36-32\lib\site-packages\pywinauto\controls\uiawrapper.py", line 132, in __get__
value = self.fget(obj)
File "C:\Users\sandy\AppData\Local\Programs\Python\Python36-32\lib\site-packages\pywinauto\controls\uiawrapper.py", line 224, in iface_selection_item
return uia_defs.get_elem_interface(elem, "SelectionItem")
File "C:\Users\sandy\AppData\Local\Programs\Python\Python36-32\lib\site-packages\pywinauto\uia_defines.py", line 236, in get_elem_interface
raise NoPatternInterfaceError()
pywinauto.uia_defines.NoPatternInterfaceError
解决方案
NoPatternInterfaceError
表示此操作未在应用端实现。SelectionItem 模式通常可用于 ListItem 或 TreeItem 元素。
对于超链接的使用方法.invoke()
。
推荐阅读
- python - python中的DFA最小化器
- flutter - 连续对齐容器的末尾
- c# - Gong Wpf DragDrop:我无法在 DragOver 和 Drop 方法中使用 DragEventArgs 获取鼠标位置
- python-3.x - 如何检查一个十六进制数是否包含另一个十六进制数
- azure - 如何限制服务原则访问 ADLS Gen2 中的特定文件夹?
- firebase - 将 ghostscript 与 firebase 云功能一起使用时产生 EACCES 错误
- javascript - 减少数组以从左到右删除重复的 matchId 条目
- jenkins - Jenkins Pipeline 作业以获取另一个 jenkins 作业构建状态
- python - 将键映射到字典熊猫中的多个值
- wordpress - 使用 Wordpress 本机类 VS 使用 AWS Lambda 调整图像大小