Matteo NNZ
Matteo NNZ

Reputation: 12665

Control an existing application with Python

I have been programming with Python for some time and noticed that it's possible to interact, for example, with MS Excel files through the library XLWT.

Now I would like to know if it's possible to use Python to control other applications, such as the Calculator.exe which is on the standard Windows path C:\Windows\system32.

Is there any way to write a script with Python, let's say, to make the calculator opening and executing 9+3=? I usually like to write some code myself first and ask for help later, but here I've no clue even if it's possible and my researches on Internet have yield only this script to launch the program:

import subprocess
subprocess.call("C:\Windows\system32\calc.exe")

Any help, suggestion or even just "no, it's not possible" would be highly appreciated.

Upvotes: 2

Views: 2275

Answers (1)

Alfe
Alfe

Reputation: 59436

It will always depend on the cooperativity of the other program. If it allows being tweaked, it will offer an API for this (and hopefully a documentation telling you how to use it).

This is not really a Python question because it rather depends on how the API is written. If this API comes as a C library, you will have to write at least a bit of C code to access it via Python. If it is a way of calling the program (special options, etc.) then Python will have as much or less trouble providing these as any other programming language.

Upvotes: 3

Related Questions