Omnifocus和AppleScript.

I’m新到mac,但大多数都知道你给我的东西,我’m希望自动执行我可以掌握的任务。 ★正如我的生活在需求的情况下,如果我能够让电脑为我做工作,我会。灾难罢工,当我生命中的任何事情太过手动时 -

lucy_disaster.

其中一个任务是我的每周报告给我的老板告诉他什么项目我’m on and what I’完成了,我将做即将到来的一周。

使用omifocus工作简单

重要的是让我保持任务,所以我发现了我尝试的数字个人项目管理计划 omn​​ifocus. 最好适合我为工作所做的事情。 Â我的老板获得了推荐的信誉,因为我试过了几个。我最喜欢应用程序是最重要的’非常自定义,我能够个性化它以满足我的需求。这包括备份计划的能力,将其移动到它’具有云支持的PRO版本,并将其保留在我的手机上。

我添加的一些自定义项目:

  1. 我使用标志表示任务是高优先级的。
  2. 我使用不同的视角来分类视图
  3. 我使用像真正的注释垫等音符部分,并将所有音符保留在Omnifocus中的不同会议。
  4. 能够用点击按钮查看我的项目,看看用不同的角度看几周的地平线。
  5. 备份到omnifocus’云或您自己选择的备份位置。
  6. 在系统中构建低,中和高中,向系统通知我的经理我认为,我认为任务在我的列表中的优先级。

Apple脚本报告

卖给我的下一个功能 AppleScript。与服务器一起使用的人知道能够通过脚本自动执行进程并将其安排在Cron或其他主机调度程序中的奖励。 AppleScript是Mac’S shell / command / powershell的版本,无论您要使用的其他引用,都在Mac上脚本。

语法是相当简单的,所以最长的学习是特定应用程序的专有呼叫,如omnifocus。幸运的是,有一些人喜欢这个方法并通过有一些例子来拯救我很多时间。我的需求可能有点不同,但他们给了我一些类似的电话,即我能够来自。

每周_rpt.scpt.

(*
======================================
// Clean up
======================================
*)

set scrpt_dir to POSIX path of "/<insert Parent Directory to omnifocus>/com.omnigroup.OmniFocus2/Data/Documents/" --Set Global Working Directory
set plist_ to ((path to "pref" as text) & scrpt_dir & "listoftasks.txt")
tell application "Finder"
 if exists file plist_ then
display dialog "It exists."
delete file plist_
 end if
end tell
set plist2_ to ((path to "pref" as text) & scrpt_dir & "mainProjects.txt")
tell application "Finder"
 if exists file plist2_ then
display dialog "It exists."
delete file plist2_
 end if
end tell

(* 
======================================
// Create Project list-- working on this section-  still won't build out flagged tasks
======================================
*)

tell application "omn​​ifocus."
 set list_Projects to {}
 set oDoc to default document
 set nofolder_Projects to (name of (flattened projects of oDoc where its folder is missing value and its status is active))
 set folder_Projects to (name of (flattened projects of oDoc where hidden of its folder is false and its status is active))
 set projNames to nofolder_Projects & folder_Projects 
 set projects_Sorted to my simple_sort(projNames)
 set old_delim to Applescript.'s text item delimiters
 set Applescript.'s text item delimiters to return
 set projects_Sorted to projects_Sorted as text
 set old_delim to Applescript.'s text item delimiters
 set Applescript.'s text item delimiters to return
 set Applescript.'s text item delimiters to old_delim
 set ExportList to "Current List of Working Projects" & return & "---" & return & (current date) & return & return as text
 tell default document
 set refFolders to a reference to (flattened folders where hidden is false)
 repeat with idFolder in (id of refFolders) as list
 set oFolder to folder id idFolder
 set ExportList to ExportList & my IndentAndProjects(oFolder) & return
 end repeat

 set ExportList to ExportList & return & return & "---" & return & return
 set week_ago to (current date) - 7 * days
 set refDoneInLastWeek to a reference to (flattened tasks where (completion date ≥ week_ago) and name of folder of its containing project is not "Personal" and name of folder of its containing project is not "Management" and name of folder of its containing project is not "Someday/Maybe")
 set {lstName, lstContext, lstProject, lstDate} to {name, name of its context, name of its containing project, completion date} of refDoneInLastWeek
 set strText to ""
 repeat with iTask from 1 to length of lstName
 set {strName, varContext, varProject, varDate} to {item iTask of lstName, item iTask of lstContext, item iTask of lstProject, item iTask of lstDate}
 if varDate is not missing value then set strText to strText & short date string of varDate & " - "
 if varProject is not missing value then set strText to strText & " [" & varProject & "] - "
 set strText to strText & strName
 if varContext is not missing value then set strText to strText & " *@" & varContext & "*"
 set strText to strText & "  " & return
 end repeat
 end tell

 set old_delim to Applescript.'s text item delimiters
 set Applescript.'s text item delimiters to return
 set projects_Sorted to projects_Sorted as text
 set Applescript.'s text item delimiters to old_delim
 set ExportList to "Current List of Active Projects:" & return & (current date) & return & return & projects_Sorted as Unicode text
 set POSIXmr to POSIX path of scrpt_dir & "mainProjects.txt"
 tell application "System Events"
 set fid to open for access POSIXmr with write permission
write ExportList to fid
close access fid
 end tell
end tell

(*
======================================
// Create List of Tasks (Completed and Upcoming)
======================================
*)

tell application "omn​​ifocus."
 set ExportList to "Upcoming Tasks and Recently Completed" & return & "---" & return & (current date) & return & return as Unicode text
 tell default document
 set ExportList to ExportList & return & return & "By Project and Due Date" & return & "---"
 set due_time to (current date) + 8 * days
 set tasksnm to a reference to (flattened tasks whose flagged is true and completed is false and due date < due_time) --Flagged and isn't completed
 set {lstName, lstContext, lstProject, lstDate} to {name, name of its context, name of its containing project, completion date} of tasksnm
 set strText to ""
 repeat with iTask from 1 to length of lstName
 set {strName, varContext, varProject, varDate} to {item iTask of lstName, item iTask of lstContext, item iTask of lstProject, item iTask of lstDate}
 if varProject is not missing value then set strText to strText & " [" & varProject & "] - " --this is good
 set strText to strText & strName
 if varContext is not missing value then set strText to strText & " *@" & varContext & "*" --this is used
 set strText to strText & " " & return
 end repeat
 end tell

 set ExportList to ExportList & strText & "" as Unicode text
 set POSIXmr to POSIX path of scrpt_dir & "listoftasks.txt"
 tell application "System Events"
 set fid to open for access POSIXmr with write permission
write ExportList to fid
close access fid
 end tell
end tell

(* 
======================================
// UTILITY SUBROUTINES 
======================================
*)

 simple_sort(my_list)
 set the index_list to {}
 set the sorted_list to {}
 repeat (the number of items in my_list) times
 set the low_item to ""
 repeat with i from 1 to (number of items in my_list)
 if i is not in the index_list then
 set this_item to item i of my_list as text
 if the low_item is "" then
 set the low_item to this_item
 set the low_item_index to i
 else if this_item comes before the low_item then
 set the low_item to this_item
 set the low_item_index to i
 end if
 end if
 end repeat
 set the end of sorted_list to the low_item
 set the end of the index_list to the low_item_index
 end repeat
 return the sorted_list
end simple_sort

(* 
======================================
// Create Top Tasks and Email
======================================
*)

set theRecipient to "<insert email address>" --Your manager's email address--Update Email Address
set theSubjectOfMessage to "Weekly Status Report for <Enter Your Name>" --The Subject of Email--  Update name in Subject
set theSender to "<Enter Your Name>"
set POSIXtl to POSIX path of scrpt_dir & "mainProjects.txt"
set POSIXmr to POSIX path of scrpt_dir & "listoftasks.txt"
tell application "Mail"
 set theMessage to make new outgoing message with properties {subject:theSubjectOfMessage, sender:theSender}
 tell content of theMessage
make new attachment with properties {file name:POSIXtl} at after last paragraph --Will be used to send second report with completed tasks
make new attachment with properties {file name:POSIXmr} at after last paragraph
 end tell
 tell theMessage
make new to recipient with properties {address:theRecipient}
 end tell
send theMessage
end tell



报告

脚本所做的是在电子邮件中创建两个附件 -

  1. 项目清单
  2. 即将推出的标记,(高优先级任务)和列表或最近完成的任务列表。

您可以通过用自己的电子邮件地址替换收件人的电子邮件地址以及确保电子邮件主题的工作目录和小型信息等来测试脚本之前测试脚本。我发现的一件事是苹果脚本喜欢缓存报告,这样’为什么我在报告中添加了一个清理的步骤以在创建新的内容之前删除任何文件。

安排脚本

苹果电脑附带一个可爱的应用程序,称为自动化器。它’非常简单,通过自动化器安排这样的脚本。在这儿’如果你没有,那么了解如何与自动化器一起使用自动化器’t before.  I’d check 他们 出来,这将拯救我从很多解释… 🙂

通过将此解决,您只需通过您的所有任务,完成以及剩余的所有任务,将由Omnifocus,Apple脚本和自动化器进行静止地保留Omnifocus!

享受!

 

dbakevlar.

http://about.me/dbakevlar

4 thoughts on “omn​​ifocus. and AppleScript

  • 2016年8月20日上午10:18
    永久链接

    谢谢你的分享!一世’已经是一个很长时间的omnifocus用户,但从来没有动机一起玩它的AppleScript能力。你的博客只是给了我我需要的推动。 ðÿ™,

  • 2016年8月21日晚上9:10
    永久链接

    我收到以下错误。

    错误“可以制作‫fcar»id“lVyQt2P2EcO”\ \ as fcdo»应用程序“OmniFocus”进入预期的类型。”来自«FCAR»ID的数字-1700“lVyQt2P2EcO” of «class FCDo»

    它似乎在这条线上
    将exportlist设置为exportlist&我的IndentandProjects(Ofolder)& return

  • 2016年8月22日上午9:37
    永久链接

    嗨斯科特 - 如果您查看错误的这一部分:“”lVyQt2P2EcO”\ \ as fcdo»应用程序“OmniFocus”进入预期的类型。” number”挑战是它的数据’从omnifocus拔出。一世’我期待一个数字和你’在您的数据中传递char。我不’知道它是否必须与全系列的版本或什么?我没有’有这个问题,但我不’T使用延迟日期等。在我的情况下,有许多区域通过日期解析。一世’D查看您的任务,看看您是否有奇数日期格式。

  • Pingback: 新的Apple脚本和omnifocus的透视– DBA Kevlar

评论被关闭。