Skip to content

Instantly share code, notes, and snippets.

@xenatt
Forked from romainbriche/TweetViaTweetbot.applescript
Last active December 16, 2015 13:29
Show Gist options
  • Save xenatt/5442335 to your computer and use it in GitHub Desktop.
Save xenatt/5442335 to your computer and use it in GitHub Desktop.
--Original form
-- TweetViaTwitter.applescript
-- Copy title and URL in the front most window of Safari to Twitter with link
-- Author: Romain Briche
tell application "System Events"
if not (exists application process "Wedge") then
tell application "Wedge" 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
end tell
on error
tell application "iTunes"
set curTrack to current track
end tell
end 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 tell
tweet("#NowPlaying " & ucurTrack & " - " & curArtist & " - " & curAlbum)
on tweet(theText)
if number of characters of theText > 140 then
return false
end if
set theScript to "require 'osx/cocoa';p=OSX::NSPasteboard.pasteboardWithUniqueName;p.setString_forType(ARGV[1],OSX::NSStringPboardType);OSX::NSPerformService(ARGV[0], p);"
do shell script "/usr/bin/ruby -e " & quoted form of theScript & " " & quoted form of "Tweet" & " " & quoted form of theText
tell application "System Events" to keystroke return using command down
return true
end tweet
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment