使用AppleScript设置OmniFocus选定的Task的tag和时间

思路

  1. 获取要添加的时间
  2. 获取OmniFocus显示窗口中的被选task
  3. 设置task的时间和tag

代码

将下面代码保存为“TaskToKM.scpt”

tell application "OmniFocus"
	tell its document "OmniFocus"
		set tagKMShare to flattened tag "km-share"
	end tell
	tell front window
		set selTree to selected trees of content
		set selTask to value of item 1 of selTree
		set due date of selTask to missing value
		set defer date of selTask to missing value
		set repetition rule of selTask to missing value
		set completion date of selTask to missing value
		set dropped date of selTask to missing value
		add tagKMShare to tags of selTask
	end tell
end tell

OmniFocus设置

  1. 在OmniFocus的help菜单中,选择“Open Script Folder”;
  2. 将上述代码文件拷贝进去;
  3. 打开自定义工具栏:
  4. 将其中的“TaskToKM.scpt”图标拖拽到工具栏

测试

选定一个task任务,点击TaskToKM脚本按钮,task被清除所有时间,并被标记tag:

测试之前:

测试之后:

Leave a Reply

Your email address will not be published. Required fields are marked *