AppleScriptでTwitter
AppleScriptでTwitterのメッセージを送信したいって友達が言ってた。簡単なコードを作ってみた…
try tell application "Finder" activate set twitter_dlg to display dialog "Twitterのメッセージ:" buttons {"キャンセル", "送信"} default button 2 default answer "メッセージを書いて下さい…" set dlg_result to (button returned of twitter_dlg) if dlg_result = "送信" then set twitter_msg to (text returned of twitter_dlg) -- Logging in to twitter... 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 -- post to twitter set twitter_status to quoted form of ("status=" & twitter_msg) set results to do shell script "curl --user " & twitter_login & " --data-binary " & twitter_status & " http://twitter.com/statuses/update.json" -- ここからはGROWL専用… tell application "GrowlHelperApp" -- Make a list of all the notification types -- that this script will ever send: set the allNotificationsList to {"TwitterNotification"} -- Make a list of the notifications -- that will be enabled by default. -- Those not enabled by default can be enabled later -- in the 'Applications' tab of the growl prefpane. set the enabledNotificationsList to {"TwitterNotification"} -- Register our script with growl. -- You can optionally (as here) set a default icon -- for this script's notifications. register as application "Twitter Updater" all notifications allNotificationsList default notifications enabledNotificationsList icon of application "Finder" -- Send a Notification... notify with name "TwitterNotification" title "Twitterメッセージ送信完了" description twitter_msg application name "Twitter Updater" end tell end if end tell end try
このAppleScriptをショートカットキーにバインドしてれば、どこからでも指定したキーを押して、メッセージを書いて、送信…エラーチェックとかはやってないので、要注意。ダウンロードは http://homepage.mac.com/saint_nus/.Public/TwitterAppleScript.zip へどうぞ。