Forked from romainbriche/TweetViaTweetbot.applescript
Last active
December 16, 2015 13:29
-
-
Save xenatt/5442326 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- 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 "Tweetbot") then | |
tell application "Tweetbot" 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 "Tweetbot" to activate | |
copyTrackAndAlbumToTweetbot(ucurTrack, curAlbum, curArtist) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment