08/14 Twitter.app投稿テスト1
Twitterの公式Mac OS X用クライアント「Twitter.app」(Mac AppStoreから無料ダウンロード)を使ってTwitterに投稿を行うAppleScriptです。
Twitter.app自体はAppleScriptに対応しているものの、投稿のための命令が存在していなかったので(ASに解放されている機能はタイムラインなどの情報取得)、GUI Scripting経由で投稿を行わせてみました。
Twitter.appにユーザーアカウントとパスワードが設定してあって、ネットワーク接続が行えていることが実行の前提条件です。また、GUI Scriptingがオンになっている必要があります。
| スクリプト名:Twitter.app投稿テスト1 |
postTweet(“テスト投稿 from AppleScript+Twitter.app”) of me –Twitter.appでTwitter投稿を行う(GUI Scripting経由) –GUI Scriptingがオンになっていることが実行条件 on postTweet(aMessage) activate application “Twitter” –activateを行わないとうまく動かない…. tell application “System Events” tell process “Twitter” –File > New Tweet … click menu item 1 of menu 1 of menu bar item 3 of menu bar 1 tell text area 1 of window 1 set value to aMessage end tell –Tweet button click button 2 of window 1 end tell end tell end postTweet |
