我已经使用pywinauto连接到一个windows应用程序,如下所示,
import subprocess
sp = subprocess.call("start shell:AppsFolder\myapp!App", shell=True)
from pywinauto import application
app = application.Application(backend="uia")
my_app = app.connect(title="myapp", class_name="ApplicationFrameWindow")
但这是通过Python的RPyC连接实现的。
第一次,这段代码运行良好,但是如果我再次使用相同的RPyC连接运行我的脚本,我会看到以下错误:
File "C:\Python27\lib\site-packages\pywinauto\application.py", line 944, in connect
self.process = findwindows.find_element(**kwargs).process_id
File "C:\Python27\lib\site-packages\pywinauto\findwindows.py", line 84, in find_element
elements = find_elements(**kwargs)
File "C:\Python27\lib\site-packages\pywinauto\findwindows.py", line 197, in find_elements
cache_enable=True)
File "C:\Python27\lib\site-packages\pywinauto\uia_element_info.py", line 272, in children
return self._get_elements(IUIA().tree_scope["children"], cond, cache_enable)
File "C:\Python27\lib\site-packages\pywinauto\uia_element_info.py", line 261, in _get_elements
ptrs_array = self._element.FindAll(tree_scope, cond)
COMError: (-2147024809, 'The parameter is incorrect.', (None, None, None, 0, None))
如果我关闭现有的RPyC连接并打开另一个会话,那么上面的代码就可以正常工作。我不能弄清楚为什么我看到这个错误。有什么想法吗?
发布于 2018-01-09 16:16:03
这是一个已知的问题,已经在主分支中修复。将很快以pywinauto==0.6.4的形式发布。
https://stackoverflow.com/questions/48076167
复制相似问题