pythonpywinautorpyc

COM error while reconnecting to UIA app using Pywinauto through RPyC


I have connected to a windows app using pywinauto like below,

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")

but this is through Python's RPyC connection.

For the first time, this code works fine but if I run my script again using same RPyC connection, I see the following error:

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))

If I close existing RPyC connection and open another session then the above code works fine. I could not able to figure out why I see this error. Any ideas?


Solution

  • It’s a known issue already fixed in master branch. Will be released soon as pywinauto==0.6.4.