13

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?

1

6 Answers 6

13

You can also use pywinauto for GUI automation.

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

Sign up to request clarification or add additional context in comments.

Comments

4

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

2 Comments

Please 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.
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.
2

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.

2 Comments

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 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..
@swanson, how does sikuli compare to other to pywinauto or pyautogui or autopy?
1

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.

2 Comments

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?
The sendkeys site is down at the moment and it isworth mentioning that Automa is a commercial package - $99 for personal use.
1

Find out how to do what you want using commands (on the command line) and script these commands instead.

4 Comments

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, I'm not familiar with the tools you're using, but I'd assume there's something about this burried somewhere on MSDN
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.
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?
0

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.