I have seen this post mentioned there is an AutoIt3 COM version, and with it I can call AutoIt functions in Python.
I couldn't find the COM version at the AutoIt website. Is it hidden somewhere? How can I get it?
There are two methods for using AutoIt in Python:
The pyautoit module will make use of the DLL while with pywin32 we can use the COM. As far as I know, there is no functional difference between the two.
Not all AutoIt functions are available through the COM/DLL interface. To see which functions are, see the help file on AutoItX.
Install via pip or your preferred method:
pip install -U pyautoit
If you get an error: WindowsError: [Error 193] %1 is not a valid Win32 application
when installing pyautoit, use the 32 bit version of python. I haven't been able to get pyautoit to install using the 64 bit version of python. Of course, your mileage may vary.
Import and use:
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")
The autoit commands all use lower_case_with_underscores rather than AutoItX's preferred CamelCase. Thus ControlSend becomes control_send, WinClose becomes win_close, etc.
Once pywin32 is installed, call AutoItX functions by:
import win32com.client
autoit = win32com.client.Dispatch("AutoItX3.Control")
autoit.Run("NotePad.exe")
autoit.ControlClick(WINDOW, "", "[CLASSNN:TTreeView1]", "left", 1, 53, 41)
If you have trouble with this version, install everything as 32 bit and try again.