In this entry I want to give you some instructions how to install and use an applescript as a LaunchBar Action.
1. Copy the following code
- Code: Select all
-- This script was put together with the help of the following sources:
-- http://blog.codahale.com/2007/01/15/tweet-twitter-quicksilver/ by Coda Hale
-- http://i.grahamenglish.net/540/iquicktwitter-my-quicksilver-twitter-ichat-growl-hack/ by Graham English
-- http://www.leancrew.com/all-this/2009/02/url-shortening-scripts-fixed-i-think/ by @drdrang (fix for &ersand issues)
-- put together and adapted by @ptujec to work with LaunchBar
-----------------------------------------------------------------------
-- take string from LaunchBar
on handle_string(tweet)
-- do wordcount
if length of tweet > 140 then
my growlRegister()
growlNotify("Tweet too long", ("(" & length of tweet as text) & ") characters")
return nothing
end if
--do tweetescape
set tweet_new to tweetescape(tweet)
-- take logininformation from keychain
tell application "Keychain Scripting"
set twitter_key to first Internet key of current keychain whose server is "twitter.com"
set twitter_login to quoted form of (account of twitter_key & ":" & password of twitter_key)
end tell
-- update twitter
set twitter_status to quoted form of ("source=launchbarat&status=" & tweet_new)
set results to do shell script "curl --user " & twitter_login & " --data-binary " & twitter_status & " http://twitter.com/statuses/update.json"
-- display dialog results
my growlRegister()
-- you can change "Tweet" into a diffent text e.g. "Zwitscher"
growlNotify("Tweet", tweet)
end handle_string
-- fix for &ersand issues (by @drdrang)
on tweetescape(tweet)
set cmd to "\nfrom urllib import quote\nprint quote(\"\"\"" & tweet & "\"\"\", \"/:\")\n"
return (do shell script "python -c " & (quoted form of cmd))
end tweetescape
-- additional scripting for Growlnotificati
using terms from application "GrowlHelperApp"
on growlRegister()
tell application "GrowlHelperApp"
register as application "Tweet" all notifications {"Alert"} default notifications {"Alert"} icon of application "Launchbar.app"
end tell
end growlRegister
on growlNotify(grrTitle, grrDescription)
tell application "GrowlHelperApp"
notify with name "Alert" title grrTitle description grrDescription application name "Tweet"
end tell
end growlNotify
end using terms from
2. Open Script Editor ("/Applications/AppleScript/Script Editor.app")
3. Paste the code into the empty window of Script Editor. Save it as "Tweet" in the LaunchBar Actions Folder ("~/Library/Application Support/LaunchBar/Actions")
4. Restart LaunchBar
5. Tweet!
Now invoke LaunchBar and start typing "TWEET" until it comes up. (You can asign a abbreviation like a simple "T" with cmd+alt+A for the next time) Than hit the spacebar and write your Tweet. Press return.
And that should be it. Its a very fast way to post a tweet.
If you are using Growl (http://www.growl.info/) you will get a notification with your Tweet, so you know your Tweet was successful submitted.
Have fun!

