yinkaisheng / Python-UIAutomation-for-Windows

🐍Python 3 wrapper of Microsoft UIAutomation. Support UIAutomation for MFC, WindowsForm, WPF, Modern UI(Metro UI), Qt, IE, Firefox, Chrome ...
Apache License 2.0
2.5k stars 477 forks source link

找控件, 经常会间歇性的遇到这个问题 _ctypes.COMError #175

Open hzh-hzh opened 3 years ago

hzh-hzh commented 3 years ago
if not profile_hyperlink.Exists(15):

File "C:\Users\C950R_V18_Athena\AppData\Local\Programs\Python\Python39\lib\site-packages\uiautomation\uiautomation.py", line 6387, in Exists control = FindControl(self.searchFromControl, self._CompareFunction, self.searchDepth, False, self.foundIndex) File "C:\Users\C950R_V18_Athena\AppData\Local\Programs\Python\Python39\lib\site-packages\uiautomation\uiautomation.py", line 8288, in FindControl for child, depth in WalkControl(control, findFromSelf, maxDepth): File "C:\Users\C950R_V18_Athena\AppData\Local\Programs\Python\Python39\lib\site-packages\uiautomation\uiautomation.py", line 8169, in WalkControl child = lastControl.GetFirstChildControl() File "C:\Users\C950R_V18_Athena\AppData\Local\Programs\Python\Python39\lib\site-packages\uiautomation\uiautomation.py", line 6256, in GetFirstChildControl ele = _AutomationClient.instance().ViewWalker.GetFirstChildElement(self.Element) _ctypes.COMError: (-2147220991, 'An event was unable to invoke any of the subscribers', (None, None, None, 0, None))

yinkaisheng commented 3 years ago

image

xiaohuihui093 commented 2 years ago

这个问题还是挺常出现的

yuanweihuaskhb commented 1 year ago

第一遍打卡窗口执行GetValuePattern().SetValue(info) ,反复多次操作都没有问题,但关闭窗口后再打开,再次执行GetValuePattern().SetValue(info) ,必现报 File "D:\soft_install\python3.8.8\lib\site-packages\uiautomation\uiautomation.py", line 5541, in SetValue ret = self.pattern.SetValue(value) == S_OK _ctypes.COMError: (-2147220992, None, (None, None, None, 0, None))

seabascuit commented 2 months ago

我有一个成功的临时措施 出问题时的代码

        study_expander = ReviewControl().study_list_expander()
        if study_expander and study_expander.Exists():
            study_expander.GetExpandCollapsePattern().Expand()

报错 Expand()ret = self.pattern.SetValue(value) == S_OK _ctypes.COMError: (-2147220992, None, (None, None, None, 0, None))

但是改成

        if study_expander.IsEnabled and study_expander.Exists():
            study_expander.GetExpandCollapsePattern().Expand()

就不再报错了