[PYTHON] I touched PyAutoIt for a moment

I tried using PyAutoIt in my business, so I will write it as a memorandum.


What is PyAutoIt

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.

What is AutoIt in the first place?

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.

Environmental information required to use PyAutoIt

# 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

1. Install PyautoIt

  1. Start a command prompt
  2. Type pip install pyautoit

Install PyAutoIt


$ pip install pyautoit

2. Install AutoIt

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.

  1. Download the latest version from AutoIt's official website Download. v3.3.14.5 (as of July 2020)
  2. Open the downloaded Setup.exe and install it
  3. Next-> Agree-> Install according to the screen
  4. Make sure that Au3Info.exe / Au3Info_64.exe is included in C: \ Program Files (x86) \ AutoIt3.

Reference page: http://auto-pc.neginukide.com/?p=27

How to use PyAutoIt

PyAutoIt can only be automated. Use Au3Info.exe to get information about what to automate (GUI).

Functions that can be used with PyAutoIt

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 /)

Operation example (Au3Info.exe)

  1. When you start Au3Info.exe, you will see a screen like this 1.png

  2. Drag the part in the red frame to the location of the window you want to operate. 2.png

  3. Select the Control tab to get the window information of the dragged part. 3.png

I will write the code based on the acquired window information

Sample code

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")

I actually moved it (demo video)

** Operation details **

  1. Open Notepad
  2. Type "Hello World!"
  3. Close Notepad without saving

sample.gif

How to use AutoIt

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

I touched PyAutoIt for a moment
I made a dash docset for Holoviews
I touched "Orator" so I made a note
I made a library for actuarial science
I touched HaikuFinder
I touched Flask
I made a python dictionary file for Neocomplete
I made a spare2 cheaper algorithm for uWSGI
I touched graph-rcnn which generates a scene graph
I made a useful tool for Digital Ocean
I created a Dockerfile for Django's development environment
I made a downloader for word distributed expression
I made a peeping prevention product for telework.
I installed Chainer, a framework for deep learning
〇✕ I made a game
I made a user management tool for Let's Chat
I made a window for Log output with Tkinter
I made a cleaning tool for Google Container Registry
I made a VM that runs OpenCV for Python
The concept of reference in Python collapsed for a moment, so I experimented a little.
A summary of what I have touched like a blog
I built a Wheel for Windows using Github Actions
[Python] I made a classifier for irises [Machine learning]
A memo that I touched the Datastore with python
I got a sqlite3.OperationalError
I touched TensorFlow's Tensorboard
I tried a simple RPA for login with selenium
I touched AWS Chalice
I touched the latest automatic test tool "Playwright for Python"
Convenient for training newcomers? I wrote a Telnet practice server
I wrote a demo program for linear transformation of a matrix
[VSCode] I made a user snippet for Python print f-string
Building a Hy environment for Lisper who hasn't touched Python
I tried using Tensorboard, a visualization tool for machine learning
I made a resource monitor for Raspberry Pi with a spreadsheet
I made a learning kit for word2vec / doc2vec / GloVe / fastText
I made a face diagnosis AI for a female professional golfer ③
I tried to create a bot for PES event notification
Aim for GIS Master # 3 I investigated a mesh-like Geocoding method
I want to create a Dockerfile for the time being.
I want a mox generator
I touched the Qiita API
I want a mox generator (2)
I made a python text
I touched Wagtail (2). Introducing django-extensions.
Made a command for FizzBuzz
I made a discord bot
I touched Tensorflow and keras
I searched for CD commands.
Python> I made a test code for my own external file
I searched for a similar card of Hearthstone with Deep Learning
I made a client / server CLI tool for WebSocket (like Netcat for WebSocket)
I made a lot of files for RDP connection with Python
[python] I created a follow-up correlation diagram for twitter (Gremlin edition)
I made a development environment for Django 3.0 with Docker, Docker-compose, Poetry
I made a scaffolding tool for the Python web framework Bottle
I tried to make a strange quote for Jojo with LSTM
I made a Python wrapper library for docomo image recognition API.