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?
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.
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.
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.
You can also use pywinauto for GUI automation.
Edit: There seems to be now GUI for creating the scripts, swapy.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With