リマインダーに要素を追加する[AppleScript][Reminders]
さて、Evernoteでのタスク管理環境を強化するために、Macのリマインダーを扱えるようになっておきたい。
というわけでいろいろ調べてみた。
まずリマインダーのtell。これはそのまま、
tell application "Reminders"
end tell
これでOK。新しいリマインダーを設定する時は、
tell application "Reminders"
set newToDo to make new reminder with properties {name:"タスク2", body:"タスクの中身"}
end tell
などとする。nameがタスク名(リマインダー名)、bodyが詳細になる。これが基本。
goEverのスクリプトを改変すれば、リマインダーへの速攻登録スクリプトはすぐにかけるだろう。
期限の設定はdue dateを使う。たとえばこんな感じ。
tell application "Reminders"
set duedate to (current date) + (2 * days)
make new reminder with properties {name:"Test", due date:duedate}
end tell
2行目で、現在時刻から二日目の日付を設定し、それをリマインダーの新規作成の時に用いている。これも難しくない。
こうして作られるリマインダーは標準のリストに追加されているはずである。では、追加先のリストを換えるのはどうするか。
tell application "Reminders"
set mylist to list "Test"
tell mylist
make new reminder with properties {name:"Test Reminder", body:"New Reminder"}
end tell
end tell
こういう感じでいけるようだ。これで「Test」というリストに、「Test Reminder」というタスクが登録される。
さらに、複数の要素の追加。たとえば、とあるリストの中身をリマインダーとして登録する。
tell application "Reminders"
set my_reminders to {"item4", "item3", "item2", "item1", "item"}
tell the default list
repeat with the_name in my_reminders
set this_reminder to make new reminder with properties {name:the_name as string}
end repeat
end tell
end tell
二行目でリストを作成。4つの要素がある。デフォルトのリストにtellをかけて、先ほどのリストの要素でループを回す。中身なし、リストの要素がタスク名のリマインダーが4つ登録される。
まず基本的なところはこれで良いだろう。次はリマインダーに登録されているタスクを使って、何かアクションを起こしてみよう。