I need AppleScript that, when lunched from command line, will return three things:
- current active application name; ex. "Google Chrome", "Safari", "Steam", "iTunes", "Atom" ect.
- current active application title, if there is one
- if current active application is a browser, I want the current active tab URL
examples:
- Google Chrome; AppleScript: How to get URL of Safari tab which failed to load? - Stack Overflow; https://stackoverflow.com/
- iTunes; iTunes
- iTerm2; 1. node test.js (sleep)
- Safari, GitHub - rails/rails: Ruby on Rails; https://github.com/rails/rails
I know there are some similar questions w. answers here on stackoverflow, but I am not able to pice them together to make all of this work. Would appreciate help much.
I wanted to make a script that does exactly this running in the background so that I can better keep track of my time. Here's what I came up with:
Credit goes to https://apple.stackexchange.com/a/171738 for getting me on the right track.