您好, 欢迎来到 !    登录 | 注册 | | 设为首页 | 收藏本站

在Python中调用AutoIt函数

在Python中调用AutoIt函数

在Python中使用AutoIt的方法有两种:

pyautoit模块将使用DLL,而pywin32我们可以使用COM。据我所知,两者之间在功能上没有区别。

并非所有AutoIt功能都可以通过COM / DLL接口使用。若要查看哪些功能,请参阅AutoItX上的帮助文件

通过pip或您的首选方法安装:

pip install -U pyautoit

如果出现错误WindowsError: [Error 193] %1 is not a valid Win32 application安装pyautoit时,使用32位版本的python。我无法使用python 64位版本安装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后,可通过以下方式调用AutoItX函数

import win32com.client
autoit = win32com.client.Dispatch("AutoItX3.Control")

autoit.Run("NotePad.exe")
autoit.ControlClick(WINDOW, "", "[CLASSNN:TTreeView1]", "left", 1, 53, 41)

如果您对此版本有疑问,请以32位安装所有内容,然后重试。

python 2022/1/1 18:38:04 有327人围观

撰写回答


你尚未登录,登录后可以

和开发者交流问题的细节

关注并接收问题和回答的更新提醒

参与内容的编辑和改进,让解决方法与时俱进

请先登录

推荐问题


联系我
置顶