Skip to content

Instantly share code, notes, and snippets.

@koirikivi
Last active November 6, 2019 11:59
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save koirikivi/8435565 to your computer and use it in GitHub Desktop.
Save koirikivi/8435565 to your computer and use it in GitHub Desktop.
# activewindow.scpt - track your active window and Chrome web page on OSX
# USAGE:
# while true; do osascript activewindow.scpt | tee -a log.log; sleep 1; done
# LICENSE: Public Domain
set _url to ""
tell application "System Events"
set _app to name of first application process whose frontmost is true
end tell
tell application _app
if the (count of windows) is not 0 then
set _window to name of front window
end if
if _app is "Google Chrome" then
tell application "Google Chrome"
set _url to URL of active tab of front window
end tell
end if
end tell
set _date to (do shell script "date +'%Y-%m-%d %H:%M:%S'")
return _app & ";" & _window & ";" & _url & ";" & _date
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment