Hello, I am trying to automate a app using python. I need help to send keyboard commands through python. I am using powerBook G4.
views:
171answers:
2
+1
Q:
How i can send the commands from keyboards using python. I am trying to automate mac app (GUI).
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
2009-06-03 21:00:12
+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
2009-06-04 11:10:02