Skip to content

Instantly share code, notes, and snippets.

@remixer-dec
Created September 14, 2024 00:19
Show Gist options
  • Save remixer-dec/4510b02ad817e74a1a1d025ab8791848 to your computer and use it in GitHub Desktop.
Save remixer-dec/4510b02ad817e74a1a1d025ab8791848 to your computer and use it in GitHub Desktop.
gets information about window name and app name of top window
import os
def get_window_name_with_applescript():
window_name = os.popen("osascript -e 'tell application \"System Events\" to get the name of window 1 of (first application process whose frontmost is true)'").read().strip()
process_name = os.popen("osascript -e 'tell application \"System Events\" to get the name of (first application process whose frontmost is true)'").read().strip()
return window_name, process_name
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment