Skip to content

Instantly share code, notes, and snippets.

@xenatt
Forked from romainbriche/TweetViaTweetbot.applescript
Last active December 16, 2015 16:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save xenatt/5462400 to your computer and use it in GitHub Desktop.
Save xenatt/5462400 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 "Appetizer") then
tell application "Appetizer" 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 copyTrackAndAlbumToAppetizer(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}
delay 0.2 -- to make sure the clipboard will be set correctly
keystroke "v" using {command down}
delay 0.2 -- to make sure the clipboard will be set correctly
end tell
end copyTrackAndAlbumToAppetizer
tell application "Appetizer" to activate
copyTrackAndAlbumToAppetizer(ucurTrack, curAlbum, curArtist)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment