diff current_window_title_osx.py @ 3:3d7fc94a404a

a few more inputs; daemonize
author drewp@bigasterisk.com
date Wed, 08 Mar 2023 10:57:11 -0800
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/current_window_title_osx.py	Wed Mar 08 10:57:11 2023 -0800
@@ -0,0 +1,15 @@
+from osascript import osascript
+#https://stackoverflow.com/questions/5292204/macosx-get-foremost-window-title
+
+
+def get_current_window_title():
+    _, title, _ = osascript('''
+    tell application "System Events"
+        set frontApp to name of first application process whose frontmost is true
+    end tell
+
+    tell application frontApp
+        set window_name to name of front window
+    end tell
+    ''')
+    return title
\ No newline at end of file