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?
-
You can try ClointFusion. Please find more details here : https://stackoverflow.com/a/69542053/9979728 – Mayur Patil Nov 04 '21 at 18:29
6 Answers
You can also use pywinauto for GUI automation.
Edit: There seems to be now GUI for creating the scripts, swapy.

- 9,386
- 6
- 25
- 78

- 6,029
- 6
- 44
- 76
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

- 640
- 6
- 5
-
1Please note that Automa is not free, and the version you download from the web is a time limited trial. Do not build anything using Automa if you are not willing to pay the license for it. – Alex Recarey Sep 29 '15 at 19:05
-
As of 2021 , The above links are not working and unable to track them on web and github . The above links are getting redirected to some spam looking website . Request SOF to verify the content. – yunus May 10 '21 at 06:00
Take a look at SIKULI - there have been some reports of less-than-perfect operation in Windows but it is really simple to play around with and get a simple script up and running.

- 7,377
- 4
- 32
- 34
-
Seems like it does work with python. But uses Jython. Looks really cool. It also has a IDE, where you can pretty much type and paste images https://www.youtube.com/watch?v=WGEX0dz_f_w&t=23s. The guy does some really complicated stuff and seems like its agnositic to OS as well as application.. – alpha_989 Dec 24 '17 at 02:24
-
@swanson, how does sikuli compare to other to pywinauto or pyautogui or autopy? – alpha_989 Dec 24 '17 at 02:25
You could use SendKeys to send keystrokes to the dialogs in question, and a few extra tricks if you also need mouse actions.
Or, you could use StraceNT to monitor all the system calls made as you manually go through the dialogs, and reproduce them in Python with either the Python win32 extensions or ctypes.

- 854,459
- 170
- 1,222
- 1,395
-
I think strace is what I need but I don't think its going to work as everything happens in explorer. there's just too much going on to isolate the right calls. Any advice? – tehr Mar 01 '10 at 09:35
-
The sendkeys site is down at the moment and it isworth mentioning that Automa is a commercial package - $99 for personal use. – Keith Kenny Sep 08 '13 at 17:53
Find out how to do what you want using commands (on the command line) and script these commands instead.

- 161,647
- 65
- 194
- 231
-
this seems like the best idea but I have no idea how to do this via commandline. Any idea where I should start looking? – tehr Mar 01 '10 at 07:38
-
@tehr, I'm not familiar with the tools you're using, but I'd assume there's something about this burried somewhere on MSDN – hasen Mar 01 '10 at 17:21
-
Microsoft doesn't always may ways to accomplish things via the command-line. The best you can (generally) hope for is that the API functions you need to call can be invoked from PowerShell or VBScript. There are some tasks that, though simple in the GUI, have a fairly heavy amount of programmatic work to be done (multiple object creation/configuration, etc.). In short: there are times when (even cruddy) GUI automation is the only feasible means of accomplishing what you need. – mojo Dec 21 '15 at 14:19
-
Agree.. doing is using commandline is probably the most robust method, but for a lot of 3rd party programs.. the API's may not be available. For those programs, how would you run it through the command line? – alpha_989 Dec 24 '17 at 02:32
PyAutoGUI can be installed with pip from PyPI. It's cross platform and can control the mouse & keyboard. It has the features of pywinauto and a few more on top. It can't identify windows or GUI controls, but it does have basic screenshot & image recognition features to click on particular buttons. And it's well-documented and maintained.
pip install pyautogui

- 11,566
- 10
- 64
- 92