两者功能相当,但OmniFocus3相对Microsoft To-Do List多的标签功能能有更多的维度来筛选。
Microsoft To-Do List任务-> Exchange帐户同步到Renminders -> AppleScript脚本同步到OmniFocus的收件箱再进行整理 -> AppleScript脚本同步到Calendar
选择这个流程的原因
- Microsoft To-Do List可以跨多个平台方便收集数据
- Microsoft To-Do List没有提供AppleScript Suite,用快捷键 ⌘⇧O 打开查看
- OmniFocus支持多标签,可以从不同维度去管理信息
- Calendar可以提供日历提醒,其实OmniFocus也可以看,但我不相全依赖OmniFocus。
set emptyList to {}
tell application "Reminders"
-- 在reminders的偏好设置中将默认列表设置为exchange帐户的tasks
tell default list
set rmds to reminders
-- 取tasks下面的reminders进行遍历
repeat with rmd in rmds
set aname to name of rmd
set createDate to creation date of rmd
set modDate to modification date of rmd
-- 根据当前reminder查找OmniFocus中是否有相同的reminder,如果没有就放到list中
tell application "OmniFocus"
tell default document
set inboxs to inbox tasks
set flag to false
-- display dialog inboxs
repeat with inbox in inboxs
set nm to name of inbox
if (nm = aname) then
set flag to true
end if
end repeat
if (flag = false) then
set newList to {aname}
set emptyList to emptyList & newList
-- parse tasks into document with transport text name
end if
end tell
end tell
end repeat
end tell
end tell
tell application "OmniFocus"
--遍历list写入到OmniFocus收件箱
repeat with elist in emptyList
-- display dialog elist
parse tasks into default document with transport text elist
end repeat
set emptyList to {}
end tell
前面因为没有将备注导过去,今天优化了一下代码,优化后的代码如下:
tell application "Reminders"
tell default list
set rmds to reminders
repeat with rmd in rmds
set aname to name of rmd
set bd to body of rmd
tell application "OmniFocus"
tell default document
set inboxs to inbox tasks
set flag to false
repeat with inbox in inboxs
set nm to name of inbox
if (nm = aname) then
set flag to true
end if
end repeat
if (flag = false) then
set theTask to make new inbox task with properties {name:aname, note:bd}
end if
end tell
end tell
end repeat
end tell
end tell
以下代码是参考捉虫#2 - 在 OmniFocus3 中将动作发布到日历。需要注意的是,这个同步只会同步**未完成
并且设置了预计持续时间
和截止时间
**的Task。
-- unlocked2412
-- THIS SCRIPT MAKES CALENDAR EVENTS FROM OMNIFOCUS TASKS WHOSE
-- DUE DATES AND ESTIMATED MINUTES FIELDS HAVE VALID VALUES.
property calendar_name : "Calendar" -- ENTER NAME OF YOUR CALENDAR
tell application "Calendar"
set calendar_element to calendar calendar_name
end tell
tell application "OmniFocus"
tell default document
set task_elements to flattened tasks whose ¬
(completed is false) and (estimated minutes ≠ missing value) and (due date ≠ missing value)
repeat with item_ref in task_elements
-- GET OMNIFOCUS TASKS
set the_task to contents of item_ref
set task_name to name of the_task
set task_note to note of the_task
set task_due to due date of the_task
set task_estimate to estimated minutes of the_task
-- BUILD CALENDAR DATE
set start_date to task_due
set end_date to start_date + (task_estimate * minutes)
-- CREATE CALENDAR EVENT
tell application "Calendar"
tell calendar_element
if exists (first event whose (start date = start_date) and (summary = task_name)) then
tell application "System Events"
display dialog "The task: " & task_name & " is already in your calendar"
end tell
else
make new event with properties ¬
{summary:task_name, start date:start_date, end date:end_date} at calendar_element
end if
end tell
end tell
end repeat
tell application "System Events"
display dialog "Done"
end tell
end tell
end tell
如果不使用omnifocus可以直接从reminders同步到canlendar,此脚本需要设置默认帐记为你要同步的帐户。
property calendar_name : "Calendar"
tell application "Calendar"
set calendar_element to calendar calendar_name
end tell
tell application "Reminders"
tell default account
set lsts to lists
repeat with lst in lists
set rmds to reminders of lst
repeat with rmd in rmds
set task_name to name of rmd
set task_note to body of rmd
set start_date to remind me date of rmd
set end_date to due date of rmd
set cpd to completed of rmd
if (cpd = false) and (start_date ≠ missing value) then
tell application "Calendar"
tell calendar_element
if exists (first event whose (start date = start_date) and (summary = task_name)) then
tell application "System Events"
display dialog "The task: " & task_name & " is already in your calendar"
end tell
else
make new event with properties ¬
{summary:task_name, start date:start_date, end date:end_date} at calendar_element
end if
end tell
end tell
--display dialog task_name & start_date & end_date & cpd
end if
end repeat
end repeat
end tell
end tell