Forked from timpulver/GetNameAndTitleOfActiveWindow.scpt
Created
May 20, 2021 08:21
-
-
Save chrisma/e924306f7079a4966127be9cb7e97ce4 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 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 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