Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to control a Windows application from Python

I have the application installed on my windows PC, I want to launch that application using python and select dropdown options and do some other activities in that application.

I was able to launch the application using the os.system command, but I am not able to proceed further.

I want my program to do things like: * select from a dropdown menu * click on a button

How can my application control the user interface of another application?

like image 709
Baslingappa Bhujang Avatar asked Jun 23 '16 11:06

Baslingappa Bhujang


People also ask

Can we automate Windows application using Python?

But in this article, we are going to automate windows applications. So, to automate the windows application we are going to use Python. Python offers great readability and easy-to-learn syntax. In Python, we are going to use the Pywinauto module whose sole purpose is to automate windows applications.


1 Answers

Normally, an application exposes a user interface (UI) for users, and an application programming interface (API) for programming.

  • A human being uses keyboard and mouse to work with the user interface (UI)
  • An application uses programming to work with the application programming interface (API)

The UI is designed for humans, and the API is designed for computers.

It is sometimes possible to use programming to control the user interface of another program -- so your program acts as if it were using the keyboard and mouse. This technique is often called "UI automation", and programs that do it are sometimes called "robots".

It's a big topic, and it can be quite complex. It's almost always better to use an API instead if you can: it's faster, simpler, more reliable.

If you do need to use UI automation, there are a few different tools that can help.

You are asking about Python, so here are a few UI automation tools that work with Python:

  • AutoIT is a standalone product, but you can use Python to script it.
  • PyWinAuto is designed for use from Python.
  • Sikuli uses computer vision to find parts of the screen. I believe it comes with a recording tool as well.

Just to repeat: UI automation is weird and hard. If you can possibly use an API instead, your life will be much easier.

like image 92
RJHunter Avatar answered Sep 21 '22 11:09

RJHunter