Python-UIAutomation-for-Windows
Python-UIAutomation-for-Windows copied to clipboard
使用 pycharm 无法加载 UIAutomationCore.dll., 不调试的时候可以加载
H:\CephTest\venv\Scripts\python.exe C:\PyCharm2019.1.2\helpers\pydev\pydevd.py --multiproc --save-signatures --qt-support=auto --client 127.0.0.1 --port 60858 --file H:/CephTest/TestPython.py pydev debugger: process 12568 is connecting
Connected to pydev debugger (build 191.7141.48) OK start test the cephalometric analysis program Can not load UIAutomationCore.dll. You may need to install Windows Update KB971513. https://github.com/yinkaisheng/WindowsUpdateKB971513ForIUIAutomation
Process finished with exit code -1
I meet the same issue :
Can not load UIAutomationCore.dll.
You may need to install Windows Update KB971513.
https://github.com/yinkaisheng/WindowsUpdateKB971513ForIUIAutomation
ERROR:meetingservice:Exception on / [GET]
Traceback (most recent call last):
File "C:\Users\test\AppData\Local\Programs\Python\Python37-32\lib\site-packages\flask\app.py", line 2446, in wsgi_app
response = self.full_dispatch_request()
File "C:\Users\test\AppData\Local\Programs\Python\Python37-32\lib\site-packages\flask\app.py", line 1951, in full_dispatch_request
rv = self.handle_user_exception(e)
File "C:\Users\test\AppData\Local\Programs\Python\Python37-32\lib\site-packages\flask\app.py", line 1820, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "C:\Users\test\AppData\Local\Programs\Python\Python37-32\lib\site-packages\flask\_compat.py", line 39, in reraise
raise value
File "C:\Users\test\AppData\Local\Programs\Python\Python37-32\lib\site-packages\flask\app.py", line 1949, in full_dispatch_request
rv = self.dispatch_request()
File "C:\Users\test\AppData\Local\Programs\Python\Python37-32\lib\site-packages\flask\app.py", line 1935, in dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)
File "meetingservice.py", line 20, in index
testuita.ptstartmeeting.startmeeting()
File "..\testuita\ptstartmeeting.py", line 369, in startmeeting
startmeetingByPt()
File "..\testuita\ptstartmeeting.py", line 251, in startmeetingByPt
ptWindow=findtopwin()
File "..\testuita\ptstartmeeting.py", line 245, in findtopwin
if not auto.WaitForExist(ptWindow, 60):
File "C:\Users\test\AppData\Local\Programs\Python\Python37-32\lib\site-packages\uiautomation\uiautomation.py", line 7370, in WaitForExist
return control.Exists(timeout, 1)
File "C:\Users\test\AppData\Local\Programs\Python\Python37-32\lib\site-packages\uiautomation\uiautomation.py", line 5855, in Exists
control = FindControl(self.searchFromControl, self._CompareFunction, self.searchDepth, False, self.foundIndex)
File "C:\Users\test\AppData\Local\Programs\Python\Python37-32\lib\site-packages\uiautomation\uiautomation.py", line 7678, in FindControl
control = GetRootControl()
File "C:\Users\test\AppData\Local\Programs\Python\Python37-32\lib\site-packages\uiautomation\uiautomation.py", line 7460, in GetRootControl
return Control.CreateControlFromElement(_AutomationClient.instance().IUIAutomation.GetRootElement())
File "C:\Users\test\AppData\Local\Programs\Python\Python37-32\lib\site-packages\uiautomation\uiautomation.py", line 51, in instance
cls._instance = cls()
File "C:\Users\test\AppData\Local\Programs\Python\Python37-32\lib\site-packages\uiautomation\uiautomation.py", line 62, in __init__
raise ex
File "C:\Users\test\AppData\Local\Programs\Python\Python37-32\lib\site-packages\uiautomation\uiautomation.py", line 57, in __init__
self.IUIAutomation = comtypes.client.CreateObject("{ff48dba4-60ef-4201-aa87-54103eef594e}", interface=self.UIAutomationCore.IUIAutomation)
File "C:\Users\test\AppData\Local\Programs\Python\Python37-32\lib\site-packages\comtypes\client\__init__.py", line 238, in CreateObject
obj = comtypes.CoCreateInstance(clsid, clsctx=clsctx, interface=interface)
File "C:\Users\test\AppData\Local\Programs\Python\Python37-32\lib\site-packages\comtypes\__init__.py", line 1225, in CoCreateInstance
_ole32.CoCreateInstance(byref(clsid), punkouter, clsctx, byref(iid), byref(p))
File "_ctypes/callproc.c", line 933, in GetResult
OSError: [WinError -2147221008] CoInitialize has not been called
127.0.0.1 - - [08/Sep/2019 20:21:59] "GET / HTTP/1.1" 500 -
INFO:werkzeug:127.0.0.1 - - [08/Sep/2019 20:21:59] "GET / HTTP/1.1" 500 -
这个错误是在当相应一个restful api (flask)的时候 会有这个问题。 如果不是在 restful api 中执行 方法是没有遇到这个error
I meet the same issue :
Can not load UIAutomationCore.dll. You may need to install Windows Update KB971513. https://github.com/yinkaisheng/WindowsUpdateKB971513ForIUIAutomation ERROR:meetingservice:Exception on / [GET] Traceback (most recent call last): File "C:\Users\test\AppData\Local\Programs\Python\Python37-32\lib\site-packages\flask\app.py", line 2446, in wsgi_app response = self.full_dispatch_request() File "C:\Users\test\AppData\Local\Programs\Python\Python37-32\lib\site-packages\flask\app.py", line 1951, in full_dispatch_request rv = self.handle_user_exception(e) File "C:\Users\test\AppData\Local\Programs\Python\Python37-32\lib\site-packages\flask\app.py", line 1820, in handle_user_exception reraise(exc_type, exc_value, tb) File "C:\Users\test\AppData\Local\Programs\Python\Python37-32\lib\site-packages\flask\_compat.py", line 39, in reraise raise value File "C:\Users\test\AppData\Local\Programs\Python\Python37-32\lib\site-packages\flask\app.py", line 1949, in full_dispatch_request rv = self.dispatch_request() File "C:\Users\test\AppData\Local\Programs\Python\Python37-32\lib\site-packages\flask\app.py", line 1935, in dispatch_request return self.view_functions[rule.endpoint](**req.view_args) File "meetingservice.py", line 20, in index testuita.ptstartmeeting.startmeeting() File "..\testuita\ptstartmeeting.py", line 369, in startmeeting startmeetingByPt() File "..\testuita\ptstartmeeting.py", line 251, in startmeetingByPt ptWindow=findtopwin() File "..\testuita\ptstartmeeting.py", line 245, in findtopwin if not auto.WaitForExist(ptWindow, 60): File "C:\Users\test\AppData\Local\Programs\Python\Python37-32\lib\site-packages\uiautomation\uiautomation.py", line 7370, in WaitForExist return control.Exists(timeout, 1) File "C:\Users\test\AppData\Local\Programs\Python\Python37-32\lib\site-packages\uiautomation\uiautomation.py", line 5855, in Exists control = FindControl(self.searchFromControl, self._CompareFunction, self.searchDepth, False, self.foundIndex) File "C:\Users\test\AppData\Local\Programs\Python\Python37-32\lib\site-packages\uiautomation\uiautomation.py", line 7678, in FindControl control = GetRootControl() File "C:\Users\test\AppData\Local\Programs\Python\Python37-32\lib\site-packages\uiautomation\uiautomation.py", line 7460, in GetRootControl return Control.CreateControlFromElement(_AutomationClient.instance().IUIAutomation.GetRootElement()) File "C:\Users\test\AppData\Local\Programs\Python\Python37-32\lib\site-packages\uiautomation\uiautomation.py", line 51, in instance cls._instance = cls() File "C:\Users\test\AppData\Local\Programs\Python\Python37-32\lib\site-packages\uiautomation\uiautomation.py", line 62, in __init__ raise ex File "C:\Users\test\AppData\Local\Programs\Python\Python37-32\lib\site-packages\uiautomation\uiautomation.py", line 57, in __init__ self.IUIAutomation = comtypes.client.CreateObject("{ff48dba4-60ef-4201-aa87-54103eef594e}", interface=self.UIAutomationCore.IUIAutomation) File "C:\Users\test\AppData\Local\Programs\Python\Python37-32\lib\site-packages\comtypes\client\__init__.py", line 238, in CreateObject obj = comtypes.CoCreateInstance(clsid, clsctx=clsctx, interface=interface) File "C:\Users\test\AppData\Local\Programs\Python\Python37-32\lib\site-packages\comtypes\__init__.py", line 1225, in CoCreateInstance _ole32.CoCreateInstance(byref(clsid), punkouter, clsctx, byref(iid), byref(p)) File "_ctypes/callproc.c", line 933, in GetResult OSError: [WinError -2147221008] CoInitialize has not been called 127.0.0.1 - - [08/Sep/2019 20:21:59] "GET / HTTP/1.1" 500 - INFO:werkzeug:127.0.0.1 - - [08/Sep/2019 20:21:59] "GET / HTTP/1.1" 500 -这个错误是在当相应一个restful api (flask)的时候 会有这个问题。 如果不是在 restful api 中执行 方法是没有遇到这个error
find one solution add the below code before others code UIAutomationCore = comtypes.client.GetModule("UIAutomationCore.dll") IUIAutomation = comtypes.client.CreateObject("{ff48dba4-60ef-4201-aa87-54103eef594e}", interface=UIAutomationCore.IUIAutomation)
also can refer http://irootlee.com/python_pywin32_thread/