If I create a thread that everything that it does is connected to some process and gets its top window, then the program freezes.
I debugged it a bit and seems to be stuck in comtypes._compointer_base.from_params. This is the whole trace:
... -> self.top_win = self.app.top_window() c:\python27\lib\site-packages\pywinauto\application.py(1095)top_window() -> backend=self.backend.name) c:\python27\lib\site-packages\pywinauto\findwindows.py(197)find_elements() -> cache_enable=True) c:\python27\lib\site-packages\pywinauto\uia_element_info.py(272)children() -> return self._get_elements(IUIA().tree_scope["children"], cond, cache_enable) c:\python27\lib\site-packages\pywinauto\uia_element_info.py(261)_get_elements() -> ptrs_array = self._element.FindAll(tree_scope, cond) > c:\python27\lib\site-packages\comtypes\__init__.py(970)from_param() -> return value
after entering the command in pdb, it shows this and then freezes:
(Pdb) s --Return-- > c:\python27\lib\site-packages\comtypes\__init__.py(970)from_param()-><POINTER... 41308a0> -> return value
It seems that the problem is using comtypes with threads, I tried calling pythoncom.CoInitialize () on the calling thread (as well as mostly), but that didn't help.
What can be done here?
Thanks.
source share