我见过this post提到有一个Python版本,有了它我就可以在AutoIt3中调用AutoIt函数了。
我在AutoIt网站上找不到COM版本。它藏在什么地方吗?我怎么才能得到它呢?
发布于 2012-02-21 11:05:40
如何在python中使用AutoItX COM/DLL
在Python中使用AutoIt有两种方法:
pyautoit模块将使用动态链接库,而对于pywin32,我们可以使用COM。据我所知,两者之间没有功能上的区别。
先决条件
installation of installation ofpyautoitinstallation or pywin32.installation of
并非所有的AutoIt函数都可以通过COM/DLL接口使用。要查看哪些函数,请参阅AutoItX上的帮助文件。
Pyautoit
通过pip或您首选的方法进行安装:
pip install -U pyautoit如果在安装pyautoit时出现错误:WindowsError: [Error 193] %1 is not a valid Win32 application,请使用32位版本的python.我无法使用64位版本的python安装pyautoit。当然,您的里程可能会有所不同。
导入和使用:
import autoit
autoit.run("notepad.exe")
autoit.win_wait_active("[CLASS:Notepad]", 3)
autoit.control_send("[CLASS:Notepad]", "Edit1", "hello world{!}")
autoit.win_close("[CLASS:Notepad]")
autoit.control_click("[Class:#32770]", "Button2")autoit命令使用的都是lower_case_with_underscores,而不是AutoItX的首选CamelCase。因此,ControlSend变成了control_send,WinClose变成了win_close,等等。
Pywin32
安装pywin32后,通过以下方式调用AutoItX函数:
import win32com.client
autoit = win32com.client.Dispatch("AutoItX3.Control")
autoit.Run("NotePad.exe")
autoit.ControlClick(WINDOW, "", "[CLASSNN:TTreeView1]", "left", 1, 53, 41)如果您在使用此版本时遇到问题,请将所有内容安装为32位,然后重试。
发布于 2010-07-22 01:26:36
AutoItX.dll和AutoItX3_x64.dll包含在默认安装中,位于名为"AutoItX“的目录中。有关更多信息,请查看该目录中的帮助文件AutoItX.chm。
https://stackoverflow.com/questions/3301561
复制相似问题