0

I'm a Python programmer and I was wondering if there's any module or framework that would allow me to interact with native Windows/Linux applications using python.

Let's say on Windows I have MS Outlook, so would it be possible to let's say automate MS Outlook to compose or check new emails?

I understand that Linux and Windows are different, but what I'm trying to achieve is to let's say open up an application, click on a button programmatically, etc.

I'm not sure if all of these are at all possible using python, so please enlighten me regarding what you think is possible and practical.

3 Answers 3

4

For something like Outlook, the best bet is probably using Outlook's COM (Component Object Model) with Python COM libraries.

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

Comments

3

Most applications have some kind of API.

And most of those API's are accessible with C.

Therefore, Python offers ctypes.

That's the lowest common denominator. Other API's are available, but you have to use Google to find them. Sometimes they're on PyPi. It's best to be specific and search for the specific app because there may be app-specific Python bindings. You don't know until you search.

MacOSX offers more sophisticated tools than this (via AppleScript and AppScript) but it's unique to Mac OS X.

4 Comments

AppleScript is hardly superior to, say, Office automation.
I didn't realize I was comparing with Office Automation. I thought I was comparing with ctypes. What caused you to think Office Automation was part of my answer?
Well, I didn't see why you picked AppleScript for Mac but handicapped other platforms with ctypes. Anyway, I'm just saying that there are more options than ctypes to a C API.
"handicapped other platforms with ctypes" Really? How? What words did I use that "handicapped" other platforms? I can't see that I even mentioned other platforms. Failing to itemize every other possible scripting platform is a handicap? Really? Or are you making some other point about my answer? Please provide quotes so that I know which words in my answer need to be fixed.
0

Here's an example in Windows:

Utilizing os.system will work to ping (a native command in Windows):

import os
os.system('ping google.com')

Alternatively, you can also you the recommended subprocess.Popen:

import subprocess
subprocess.Popen('echo "hello world"', shell=True)

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.