python使用win32com调用autoit时候
>>> auto = Dispatch("AutoItX3.Control")
Traceback (most recent call last):
File "
File "C:\Python27\lib\site-packages\win32com\client\__init__.py", line 95, in
Dispatch
dispatch, userName = dynamic._GetGoodDispatchAndUserName(dispatch,userName,c
lsctx)
File "C:\Python27\lib\site-packages\win32com\client\dynamic.py", line 108, in
_GetGoodDispatchAndUserName
return (_GetGoodDispatch(IDispatch, clsctx), userName)
File "C:\Python27\lib\site-packages\win32com\client\dynamic.py", line 85, in _
GetGoodDispatch
IDispatch = pythoncom.CoCreateInstance(IDispatch, None, clsctx, pythoncom.II
D_IDispatch)
pywintypes.com_error: (-2147221005, '\xce\xde\xd0\xa7\xb5\xc4\xc0\xe0\xd7\xd6\xb
7\xfb\xb4\xae', None, None)
需要在系统中先注册autoit的的dll,在管理员权限下运行以下两条命令:
REGSVR32 /S AutoItX3.dll
REGSVR32 /S AutoItX3_x64.dll(64位操作系统下需要两个都注册,32位只注册32位的dll即可)