RF添加AutoItLibrary
RF导入AutoItLibrary,显示红色的处理方法
已经完成的工作:
1.pip install AutoItLibrary成功
2.AutoIt v3安装成功
查找问题方法:
使用python脚本查看AutoItLibrary的使用是否正常,代码片
.
// 查看AutoIt的版本
import AutoItLibrary
a = AutoItLibrary.AutoItLibrary()
print a.GetAutoItVersion()
出现报错:
Traceback (most recent call last):
File "G:/study/NewTest/test.py", line 19, in <module>
a = AutoItLibrary.AutoItLibrary()
File "F:\python27\lib\site-packages\AutoItLibrary\__init__.py", line 79, in __init__
self._AutoIt = win32com.client.Dispatch("AutoItX3.Control")
File "F:\python27\lib\site-packages\win32com\client\__init__.py", line 95, in Dispatch
dispatch, userName = dynamic._GetGoodDispatchAndUserName(dispatch,userName,clsctx)
File "F:\python27\lib\site-packages\win32com\client\dynamic.py", line 114, in _GetGoodDispatchAndUserName
return (_GetGoodDispatch(IDispatch, clsctx), userName)
File "F:\python27\lib\site-packages\win32com\client\dynamic.py", line 91, in _GetGoodDispatch
IDispatch = pythoncom.CoCreateInstance(IDispatch, None, clsctx, pythoncom.IID_IDispatch)
pywintypes.com_error: (-2147024770, '\xd5\xd2\xb2\xbb\xb5\xbd\xd6\xb8\xb6\xa8\xb5\xc4\xc4\xa3\xbf\xe9\xa1\xa3', None, None)
进程已结束,退出代码1
**self._AutoIt = win32com.client.Dispatch(“AutoItX3.Control”)对“AutoItX3.Control”**的调用出错。需要在系统中注册AutoIt3的dll。
解决方法:
- 将AutoIt3的安装目录下的AutoItX3.dll、AutoItX3_x64.dll复制到windows目录下;
- 使用管理员运行CMD执行以下命令即可:(64位机器需要执行两条命令)
- REGSVR32 /S AutoItX3.dll - REGSVR32 /S AutoItX3_x64.dll
验证结果:
再次执行之前的python脚本查看AutoIt版本号,正常输出后再次在RF中导入AutoItLibrary成功。
*INFO* AutoIt: Running File: F:\python27\lib\site-packages\AutoItLibrary\__init__.pyc, Version: 1.1
*INFO* AutoIt: Running AutoItX 3.3.14.5 (COM object)
AutoItX 3.3.14.5 (COM object)
进程已结束,退出代码0