我已经使用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连接并打开另一个会话,那么上面的代码工作正常。我无法弄清楚为什么我会看到这个错误。有什么想法吗?
答案 0 :(得分:0)
这是已在主分支中修复的已知问题。即将发布pywinauto == 0.6.4。