Created
February 11, 2013 10:38
-
-
Save timpulver/4753750 to your computer and use it in GitHub Desktop.
[AppleScript] Get Name of active window | Returns the name / title of the active (frontmost) window
This file contains hidden or 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
# taken from user Albert's answer on StackOverflow | |
# http://stackoverflow.com/questions/5292204/macosx-get-foremost-window-title | |
# tested on Mac OS X 10.7.5 | |
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 | |
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} |
This file contains hidden or 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
#!/bin/bash | |
for i in `seq 1 5`; | |
do | |
echo $i | |
echo `osascript GetNameAndTitleOfActiveWindow.scpt` | |
sleep 1 | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thank you!