Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save xenatt/5476692 to your computer and use it in GitHub Desktop.
Save xenatt/5476692 to your computer and use it in GitHub Desktop.
-- base on
-- TweetViaTweetbot.applescript
-- Copy title and URL in the front most window of Safari to Tweetbot with link
-- Author: Romain Briche
tell application "System Events"
if not (exists application process "Twitterrific") then
tell application "Twitterrific" to activate
end if
if not (exists application process "iTunes") then
tell application "iTunes" to activate
else
tell application "iTunes"
if not (get player state as string) = "play" then
tell application "iTunes" to play
end if
end tell
end if
end tell
tell application "System Events"
try
tell application "iTunes"
set curTrack to current track
set ucurTrack to name of curTrack as string
set curAlbum to album of curTrack as string
set curArtist to artist of curTrack as string
end tell
end try
end tell
on copyTrackAndAlbumToTweetbot(theTrack, theAlbum, theArtist)
tell application "System Events"
set tweet to "#NowPlaying " & theTrack & " - " & theArtist & " - " & theAlbum
set the clipboard to tweet as text
delay 0.2 -- to make sure the clipboard will be set correctly
keystroke "n" using {command down}
keystroke "v" using {command down}
delay 0.2 -- to make sure the clipboard will be set correctly
end tell
end copyTrackAndAlbumToTweetbot
tell application "Twitterrific" to activate
copyTrackAndAlbumToTweetbot(ucurTrack, curAlbum, curArtist)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment