iCalの入力をもっと簡単にしよう

iCalは便利なんですが、登録の際、いちいちフォームを移動させる必要があるので面倒です。なんで以下のように入力するとTODOを作ってくれるAppleScriptを考えてみました。
なお、AppleScriptは時間のデータを渡さなければ0:00に、月もしくは年を渡さなければ現在のモノをそのまま渡すので、ちょっと調整する分岐を作ってみました。

  • 2006/8/29 あれをする
  • 8/10 12:24 これをする
  • 20:35 それもする

だと、

  • 2006年の8月29日に「あれをする」というTODOを作ります
  • 一番未来の8月10日の12時24分に「これをする」というTODOを作ります
  • 一番未来の20時35分に「それもする」というTODOを作ります

ちなみにモノに関わらず30分前にアラームを設定してありますのでその都度イジってやってください
なんか、はてなかなんかの関係でバックスラッシュ(\)が?になってるので変換してやってください

--自分のカレンダー名にしてください
property calName : "TV"

set A to text returned of (display dialog "予定を入れてください" default answer "")

set regExp to "^??s*([??d:??/??s]+)??s+(.*)"
set sendCmd to "map {print $_ . ?"??n?"}" & "($ARGV[0] =~ /" & regExp & "/)"
set getShell to do shell script "perl -e " & (quoted form of sendCmd) & space & quoted form of A
set getDate to paragraph 1 of getShell
set getSum to paragraph 2 of getShell
set setDate to date getDate

if (current date) > setDate then
	set theDiff to (current date) - setDate
	if (theDiff > 365 * 24 * 60 * 60) then
		set year of setDate to (year of setDate) + 1
	else if (theDiff > 24 * 60 * 60) then
		set month of setDate to (month of setDate) + 1 as integer
	else if (theDiff > 60 * 60) then
		set day of setDate to (day of setDate) + 1
	end if
end if


tell application "iCal"
	set A to make new todo at end of calendar calName with properties {summary:getSum, due date:setDate}
	set ALM to make new sound alarm at the end of sound alarms of A
	set trigger interval of ALM to -30
end tell

本当の事を言うと、perlを使ってTodo以外にもイベント用のを作ってあるんですが、それは内緒です。動くといいなー