In Mac 10.6, I want to cause an active application to become de-active, or minimized by Python
I know I could use sendKey in Windows with Python, then what about in Mac?
You can run a Python interpreter by double-clicking on Applications / Utilities / Terminal and typing python3 (if you've installed a version of Python 3) or python (to use Python 2) in the window that opens up.
On a Mac system, it is very straight-forward. All you need to do is open Launchpad and search for Terminal , and in the terminal, type Python and boom, it will give you an output with the Python version.
iOS does not have Python pre-installed, so you'll have to embed a copy of Python within your app. Additionally, iOS apps can't run arbitrary secondary processes, so you'll have to run the Python interpreter inside your app's process. That's quite possible, but it involves a good understanding of the Python runtime.
Here is what I found from a different question on Stack Overflow. It works pretty good for my problem.
import os
cmd = """
osascript -e 'tell application "System Events" to keystroke "m" using {command down}'
"""
# minimize active window
os.system(cmd)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With