I tried using PyAutoIt in my business, so I will write it as a memorandum.
A wrapper for AutoIt for Python. You can operate the GUI of Windwos [^ What is a wrapper]
[^ What is a wrapper]: A wrapper (Wrapper) is, roughly speaking, something that was running in another program but can be used in this program as well. If you want to know more, please try google.
AutoIt's main feature is the GUI automatic operation function of Windows programs. The script can be compiled into an executable format, and the compiled version will work even in an environment where the AutoIt interpreter is not installed. It is freeware and has a large number of libraries and development tools. Wikipedia
Official: https://pypi.org/project/autoit/ It seems that.
# | name | Description |
---|---|---|
1 | Python3 | PyAutoIt runs on Python, so of course you need it |
2 | Editor tool | VSCode,pycharm,Favorite things such as ATOM |
3 | PyAutoIT | Cannot be used without installation |
Install PyAutoIt
$ pip install pyautoit
I want to use "Au3Info.exe [^ 2]" included in AutoIt, so I also install the original AutoIt.
[^ 2]: Au3Info.exe is a convenient application that gets the window information of the operation target. Very useful for RPA and automation.
Reference page: http://auto-pc.neginukide.com/?p=27
PyAutoIt can only be automated. Use Au3Info.exe to get information about what to automate (GUI).
It seems that basically the same function as AutoIt can be used. However, please note that the usage is slightly different.
Example) In the case of ControlTreeView function AutoIt:ControlTreeView PyAutoIt: Control_Tree_View (It seems to be used with autoit.Control_Tree_View (hoge, hogehoge, hogehogehoge))
https://open-shelf.appspot.com/AutoIt3.3.6.1j/html/functions.htm
Please refer to this article for how to use Au3Info.exe. [■■■ How to use Au3Info.exe ■■■](https://cfautog.tokyo/2019/11/18/au3info-exe%E3%81%AF%E3%82%A6%E3%82%A3 % E3% 83% B3% E3% 83% 89% E3% 82% A6% E3% 81% AE% E6% 83% 85% E5% A0% B1% E3% 82% 92% E8% A6% 8B% E3 % 82% 8C% E3% 82% 8B% E4% BE% BF% E5% 88% A9% E3% 81% AA% E3% 82% A2% E3% 83% 97% E3% 83% AA /)
When you start Au3Info.exe, you will see a screen like this
Drag the part in the red frame to the location of the window you want to operate.
Select the Control tab to get the window information of the dragged part.
I will write the code based on the acquired window information
Here, write the sample code to enter "Hello World!" In Notepad.
PyAutoIt sample code(Python)
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")
** Operation details **
This page is mainly about PyAutoIt, so If you are interested in the original AutoIt, please read the article below. https://cfautog.tokyo/2020/02/27/autoit-howtouse/
Recommended Posts