Skip to content

Instantly share code, notes, and snippets.

@kaplas
Last active January 21, 2016 17:10
Show Gist options
  • Save kaplas/c2bfc2cc84a4b4bf02e1 to your computer and use it in GitHub Desktop.
Save kaplas/c2bfc2cc84a4b4bf02e1 to your computer and use it in GitHub Desktop.
A collection of useful AppleScripts

A collection of useful AppleScripts, usually to be used with OS X Automator

# Open a new Chrome ignognito tab for Gmail
if application "Google Chrome" is running then
tell application "Google Chrome"
set theURL to URL of active tab of window 1
set incogWin to make new window with properties {mode:"incognito"}
set incogTab to active tab of window 1
tell incogTab
set URL to "https://gmail.com"
end tell
end tell
else
do shell script "open -a /Applications/Google\\ Chrome.app --args --incognito https://gmail.com"
end if
tell application "Google Chrome" to activate
# Play a random album on Spotify
tell application "System Events" to set runningApps to every application process's name
if runningApps does not contain "Spotify" then
# Open Spotify on the background
do shell script "open -ga /Applications/Spotify.app"
# Hide the newly opened Spotify window
tell application "Finder"
set visible of process "Spotify" to false
end tell
end if
set spotifyUri to do shell script "curl http://www.spotifynewmusic.com/randomalbumgenerator.php\\?site\\=All\\&score\\=0\\&genrefilter\\=All\\&weeks\\=52 | grep -oh 'spotify:album:\\w*'"
tell application "Spotify" to play track spotifyUri
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment