Created
January 29, 2019 19:07
-
-
Save munro/563c87e6c01df6e816bf3e27e6b5b025 to your computer and use it in GitHub Desktop.
macos_get_focused_application
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from textwrap import dedent | |
import subprocess | |
def macos_get_focused_application(): | |
return subprocess.check_output(['osascript'], input=dedent(''' | |
tell application "System Events" | |
set frontApp to name of first application process whose frontmost is true | |
end tell | |
''').strip().encode('utf-8')).strip().decode('utf-8') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment