Apple Scriptのメモ

◆ 15秒後に自動的にスリープさせる( via http://ueshin.asablo.jp/blog/2009/02/10/4111741 )

display dialog "スリープ..." buttons {"キャンセル"} giving up after 15
tell application "Finder"
	sleep
end tell

※これ、ダイアログ表示がアクティブになってから15秒っぽくて、開いてからの純粋に15秒後に実行ってわけではないみたいです。


◆ 15秒にアプリケーション起動

display dialog "HogeApps will open after 15 sec…" buttons {"キャンセル"} giving up after 15
try
	do shell script "open -a /Applications/Hoge.app"
end try

※同上


◆ 特定のアプリケーションをアクティブにする

tell application "HogeApp"
	activate
end tell


◆ 引数指定で実行

on run argv
    return "hello, " & item 1 of argv & "."
end run

※数値として扱いたい場合は"item 1 of argv as number"とかにする


◆ ターミナルを閉じる

tell application "Terminal" to quit