Python模块PyAutoIt调用AutoIT

版权声明:本文为博主原创文章,欢迎转载,转载时请以超链接形式标明文章原始出处。 https://blog.csdn.net/lilongsy/article/details/81607272

简介

Python版本AutoIT,直接绑定到 AutoItX3.dll,然后就可以使用AutoIT的功能了。

安装

pip install -U pyautoit

例子

运行记事本,然后写入“hello world”,最后不保存关闭。

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,然后调用的方法:
1、安装pywin32

pip install pywin32

2、从autoit3\AutoItX下找到AutoItX3_x64.dll AutoitX.dll,选择对应的32位/64位版本
3、注册dll文件(注意用管理员身份调用cmd)。

regsvr32 AutoItX3_x64.dll 或regsvr32 AutoitX.dll

4、调用

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

参考

https://pypi.org/project/PyAutoIt/
https://github.com/jacexh/pyautoit
https://github.com/mhammond/pywin32
https://blog.csdn.net/sophia_slr/article/details/41847999

猜你喜欢

转载自blog.csdn.net/lilongsy/article/details/81607272