tags:

views:

171

answers:

2

Hello, I am trying to automate a app using python. I need help to send keyboard commands through python. I am using powerBook G4.

A: 

To the best of my knowledge, python does not contain the ability to simulate keystrokes. You can however use python to call a program which has the functionality that you need for OS X. You could also write said program using Objective C most likely.

Or you could save yourself the pain and use Automator. Perhaps if you posted more details about what you were automating, I could add something further.

Seamus
+1  A: 

You could call AppleScript from your python script with osascript tool:

import os
cmd = """
osascript -e 'tell application "System Events" to keystroke "m" using {command down}' 
"""
# minimize active window
os.system(cmd)
Masci