diff --git a/app/get-foreground-window-title.osa b/app/get-foreground-window-title.osa index ac74dd3d..49d1fe57 100755 --- a/app/get-foreground-window-title.osa +++ b/app/get-foreground-window-title.osa @@ -1,13 +1,15 @@ global frontApp, frontAppName, windowTitle - set windowTitle to "" + global frontApp, frontAppName, windowTitle + set windowTitle to "" tell application "System Events" - - set frontApp to first application process whose frontmost is true - set frontAppName to name of frontApp - - tell process frontAppName - set windowTitle to title of 1st window - end tell + set frontApp to first application process whose frontmost is true + set frontAppName to name of frontApp + tell process frontAppName + tell (1st window whose value of attribute "AXMain" is true) + set windowTitle to value of attribute "AXTitle" + end tell + end tell end tell + return {frontAppName, windowTitle, frontApp} \ No newline at end of file diff --git a/app/testscript.sh b/app/testscript.sh new file mode 100644 index 00000000..9e0e99b4 --- /dev/null +++ b/app/testscript.sh @@ -0,0 +1,7 @@ +#!/bin/bash +for i in `seq 1 5`; + do + echo $i + echo `osascript get-foreground-window-title.osa` + sleep 1 +done \ No newline at end of file