2011年1月20日付
前回、OmniFocusのアクションをiCalのToDoリストに、毎時書き加えるスクリプトを紹介しました。
http://kisetsutayori.seesaa.net/article/180397537.html
今回は、OmniFocusのアクションを、iCalのイベントに登録するスクリプトの紹介です。
情報元は、こちらです。
The Code Dungeon
OmniFocus Events to iCal
http://mikeerickson.wordpress.com/2010/11/29/omnifocus-events-to-ical/
このページより、「OmniFocus to iCal Package」をダウンロードしてください。
そのまま実行させると、AppleScriptが作成されます。
途中で、作成される場所が表示されますので、見逃さないでくださいね。
私は、いつものように、ポンポンポンを実行させ、「あれ、どこにできたんだ」って探しましたから(^^;
このAppleScriptでは、イベントとして登録する際に次のような条件や処理がされています。
1.iCalに登録する際のカレンダーは「OmniFocus」と設定しています。
登録時に、既存の「OmniFocus」のカレンダー(ToDoリストも含む)は削除されます。
2.OmniFocusのコンテンツが「iCal」となっているもののみを登録します。
3.アラームとして、開始時刻の15分前に音がなるようになっています。
4.開始日や期限が未設定のアクションは、このスクリプト実行日の全日イベントとして登録されます。
私は、1の「OmniFocus」というカレンダー名を「OmniFocus2」に変更、
2の登録されるコンテンツが「iCal」というものだけという条件文を変更して、
全コンテンツが登録されるように変更して使っています。
オリジナル作者のMr. Mike Ericksonに感謝して、以下、私が変更を加えたAppleScriptです。
ここから-->
(* LICENSE:
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the “Software”), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
*)
-- Create a Calendar in iCal based on OmniFocus actions with specific context
-- Copyright (c) 2010 Yilei Yang (http://www.yilei.org)
-- Version 0.1 11/28/2010
-- Version 0.2 11/28/10 - mse
-- • Added alarm creation
-- Some settings you may change
set calendarName to “OmniFocus2” -- CAUTION: This script will remove all the events & todos in calendar “OmniFocus2”
-- Change to All context 01/12/11 M.Koizumi
-- set focusContext to “iCal” -- ONLY create iCal events according to those OmniFocus actions with the “iCal” context
-- used for creating alarm
set alarmTime to -15
set alarmSound to “Blow”
-- Test calendar existance
tell application “iCal”
try
set focusCalendar to first calendar whose title is calendarName
on error msg
set focusCalendar to make new calendar with properties {title:calendarName}
end try
delete events of focusCalendar
delete todos of focusCalendar
end tell
tell application “OmniFocus”
set tasklist to flattened tasks of default document
repeat with aTask in tasklist
-- if the context of aTask is not missing value and the name of context of aTask is focusContext then
-- Change to All context create
if the context of aTask is not missing value then
set taskName to the name of aTask
set taskNote to the note of aTask
set startDate to the start date of aTask
set dueDate to the due date of aTask
set taskComplete to the completed of aTask
tell application “iCal”
if taskComplete is false then
if the startDate is not missing value and the dueDate is not missing value then
set newEvent to make new event at the end of the events of focusCalendar with properties ¬
{summary:taskName, description:taskNote, start date:startDate, end date:dueDate}
else if the startDate is not missing value then
set newEvent to make new event at the end of the events of focusCalendar with properties ¬
{summary:taskName, description:taskNote, start date:startDate}
else
set newEvent to make new event at the end of the events of focusCalendar with properties ¬
{summary:taskName, description:taskNote, allday event:true}
end if
-- create alarm when alarmTime and alarmSound values supplied
-- 2010-11-28 16:14:36, mse
if the alarmTime is not missing value and the alarmSound is not missing value then
set theAlarm to make new sound alarm at end of sound alarms of newEvent with properties {trigger interval:alarmTime, sound name:alarmSound}
end if
end if
end tell
end if
end repeat
end tell
<--ここまで
また、前回の「OmniFocusのアクションをiCalのToDoに毎時登録」と同じように
Crontabでシステムに次のように登録して自動実行をさせています。
$ crontab -l
40 * * * * osascript -e 'tell application "OmniFocus" to ical_synchronize first document'
50 * * * * osascript /Users/HOGEHOGE/Documents/Scripts/OmniFocus/OmniFocusToiCal2.scpt
$
毎時40分に、「OmniFocusのアクションをiCalのToDoに登録」をおこない、
毎時50分に、「OmniFocusのアクションをiCalのイベントに登録」をおこないます。
Crontabについては、次のサイトも参考にしてください。
Mac OS Xで、タスクをスケジューリングする。(crontabによるタスク起動)
http://ameblo.jp/z9dz9d/entry-10151724112.html
ご使用になる際は、
1.OmniFocusのアクションが登録されるiCalのカレンダー名は、何がいいか?
2.OmniFocusのアクションからiCalのカレンダーに登録する「コンテンツ」は全部か一部にするか?
3.自動実行させる場合、いつ実行させるか?
などを考慮して、どんどん書き加えて頂ければさいわいです。
現在このAppleScriptでは、「繰り返し」の設定ができません。
そこを今後手を加えることができれば、と思っています。
2011年01月20日
この記事へのコメント
コメントを書く
この記事へのトラックバックURL
http://blog.seesaa.jp/tb/181628519
※言及リンクのないトラックバックは受信されません。
この記事へのトラックバック
http://blog.seesaa.jp/tb/181628519
※言及リンクのないトラックバックは受信されません。
この記事へのトラックバック