How to control a Windows application from Python - 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?

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.

You need to install pywinauto package
Try the following code to run the .exe file
from pywinauto import application
app = application.Application()
app.start("Notepad.exe")

here you are:
(with os ^_-)
import os
os.startfile('your exe file address')

Related

Testing the user interface inside a program running on Linux

Are there libraries for automating (using Python) the management of a program run by a user on a Linux operating system?
I need to create tests to test the program interface (pressing buttons, entering text in special fields, reading text from the program window).
UPD:
pywinauto - as I understand it, this library is only suitable for managing Windows applications
UPD2:
The application that needs to be managed works on the basis of Visual Studio, maybe I can somehow connect to it using selenium?

GUI type application for Scheduling Jobs

Is there any Python library or framework that provide scheduling of Jobs in windows having GUI. By jobs, I mean some batch files or Python scripts.
An application where edit, create and deletion of jobs are available.
I have tried and looked a lot of questions, and finally mashed up.
Please suggest some library or a way to create one GUI application for the same.
I used Tkinter and PyQt5 .What I really recommend is PyQt5 for many reasons:-
1.Easy syntx
2.More human readable
and lastly there is an application created to ease and save time on designing the app
for PyQt5 which is Qt designer it's going to convert all the look of you application into python codes so all you have to do copy , paste and do the functionality like when clicking a button something happens etc. Highly recommend PyQt

How to control an outside executable application?

I have my own application on python 2.7. I want to control an outside .exe application.
I'm able to launch such an application, klm.exe as:
from win32com.client import *
ExtApp = Dispatch("Wscript.Shell")
ExtApp.Run("E:\XYZ\ABC\klm")
But I want to have full control of this outside .exe application as it has tabs, radio buttons, push buttons, etc.
Is there a way to do so?
But I want to have full control of this outside .exe application as it has tabs, radio buttons, push buttons, etc.
Is there a way to do so?
Yes, multiple ways, depending on the application.
Since you're already using COM (although I'm not sure why you're using it just to launch apps)… does the app have a COM automation (IDispatch) interface? If so, there will probably be documentation showing how to use it from VB# (or VBScript or C# or …), which you can easily adapt to Python and win32com. (For an example of such an application, see the Outlook automation docs.)
If there's no COM automation interface, there may still be a lower-level COM interface, which is almost as easy to use via win32com, but it usually won't provide any access to the GUI controls; instead, you'll be talking to the same lower-level functionality that the GUI uses. (For a good example, see Apple's iTunes COM Interface.)
If there's no COM support at all, the simplest thing to do is to automate it via Windows WM_* events. There are some examples of doing that in the pywin32 documentation, but there are also a lot of higher-level wrappers, like AutoPy and pywinauto/swapy, and so on that will make things a whole lot easier. There are dozens of these, free and commercial, and even more if you're willing to step outside of Python and use a different scripting system, and SO is not a good place to discuss the pros and cons of each.
Finally, you can always ignore the app's windows and just automate the system mouse… but this is almost always a silly thing to do.

How to load SWF content into a Python application on Linux?

I have an application that uses Flash for the GUI and Python for the core logic. This combination is awesome. Unfortunately my current approach only works on Windows, as it uses the wxPython comtypes library to embed the Flash ActiveX player. Every other aspect of the app is platform-agnostic, so I'm thinking there must be some way on Linux to have Python talk to Flash.
The SWF need not require AVM2/AS3, though ideally I could use the most current Flash player available. I am using wxPython (wxWidgets) and would prefer to keep using it. Worst case I could jerry-rig something that loads the SWF in a separate process and talks over a socket connection to the Python, but I see no simple way to have the Flash display inside my application's window rather than a player window with its own menus and decorations.
Any suggestions appreciated. I'm very open to hacking at a solution if there's reason to believe it will work :)
Flash Professional has support to Adobe Air, so you could use it as front-end, usually a flash project can be released as an AIR application without major changes to its code. The communication could be done using Native Process Api (see links bellow). Then you can run it on Mac, Win e Lin.
http://www.kirupa.com/forum/showthread.php?349728-Air2-NativeProcess-launching-Python-scripts.
http://mykola.bilokonsky.net/2010/11/adobe-air-nativeprocess-and-python-introduction/

Python Console UI Suggestions

I'm currently rewriting a perl console application that was using curses, and planning to implement it in Python. So far I've narrowed my library options to straight curses, urwid, and dialog.
The application is basically an installer for an appliance that will accommodate basic configuration (network options, hostname, etc). Are there any suggestions or advocates for one of these over the other? Any serious limitations with urwid or dialog?
urwid is a very complete UI interface and you can do almost everything. In fact, I'm developing an app using urwid. But, as Paulo Scardine said, dialog is a better choice for a wizard-like app.
Dialog is very easy to use and a good choice for an installer using 'wizard-like' interface.

Categories