2

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.

7
  • 1
    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. Commented Mar 12, 2014 at 8:26
  • @Alfe, alright. So let's say this (I'm sorry for any stupid question but I'm not a real programmer): if I'd like to programmatically repeat some behaviors of the Bloomberg interface (e.g.: writing a text, sending a file etc.), shall I look for the Bloomberg API as a Python library? Commented Mar 12, 2014 at 8:29
  • 1
    I've got your point. I looked a bit on the web and yes, you're right, I need an API offered by the company which is giving the software. Please write your first comment as an answer so I will mark it as my favourite one ;) Commented Mar 12, 2014 at 8:33
  • 1
    www.bloomberg.com? So I guess you've got a software product accessing that financial stuff site. Then, yes, try to find a Python-oriented API. If you just find sth for C/C++ you can write an adaptor to access it via Python, but if you're not a programmer, be ready to learn a lot :) Commented Mar 12, 2014 at 8:33
  • 1
    I've just found the Python-oriented API, free access from Bloomberg for Bloomberg users, exactly what I've been looking for. But I told you, I'm not a programmer so I was missing the keyword "API" to even try looking for it on the web :) Commented Mar 12, 2014 at 8:35

1 Answer 1

3

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.

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

1 Comment

For sake of completeness, the API I was looking for is win32api (to control the calculator or other Windows applications), while the library to control the Bloomberg software is BLPAPI which is free-of-charge available here in C, C++, Java, .NET, Perl and Python. Danke schon Alfe ;)

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.