Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Automate Windows GUI operations with Python

Tags:

python

winapi

I want to make a Python script that automates the process of setting up a VPN server in Windows XP, but the only way I know how to do it is using the Windows GUI dialogs. How would I go about figuring out what those dialogs are doing to the system and designing a Python script to automate it?

like image 540
tehr Avatar asked Mar 01 '10 05:03

tehr


People also ask

Can we automate GUI using Python?

In this article, we will explore how we can do GUI automation using Python. There are many modules that can do these things, but in this article, we will use a module named PyAutoGUI to perform GUI and desktop automation using python. Also, we would explore how we can automate the keyboard keystrokes.

Can Python be used to automate Windows tasks?

Common system administration tasks can take a huge amount of time, but with a Python script, you can automate these tasks so that they take no time at all.

How do you automate a desktop application in Python?

Install python and then pywinauto + pytest in your python environment (preferably in your own virtualenv) Launch your desktop app. Launch SWAPY and look at the list of apps it displays, watch for your app in that list.


2 Answers

You can also use pywinauto for GUI automation.

Edit: There seems to be now GUI for creating the scripts, swapy.

like image 165
Harriv Avatar answered Sep 21 '22 21:09

Harriv


You can try using Automa - it's a Windows automation tool which can be used as a python library:

from automa.api import *

And then you can use commands like start(..), click(..) and enter(..) which operate on UI. You can also use the tool as a standalone application, from its own console window. If a GUI element's name is not obvious, Automa offers a function called get_name_under_mouse() - you can hover your mouse over any GUI element to find out its name.

Disclosure: I'm involved in Automa's development

like image 32
Tytus Avatar answered Sep 19 '22 21:09

Tytus