-
Notifications
You must be signed in to change notification settings - Fork 26
/
Push-Due-Date.applescript
52 lines (46 loc) · 1.44 KB
/
Push-Due-Date.applescript
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
use AppleScript version "2.4" -- Yosemite (10.10) or later
use scripting additions
on run argv
set _clear to false
try
if class of argv = script or class of argv = document then
set argv to {"1", "0", "30"}
end if
if class of argv = list then
if item 1 of argv = "clear" then
set _clear to true
else
set _d to item 1 of argv as number
set _h to item 2 of argv as number
set _m to item 3 of argv as number
end if
end if
tell application "OmniFocus"
set selectedItems to my getSelection()
repeat with t in selectedItems
tell t
if _clear then
set due date to missing value
else
if due date = missing value then
set due date to ((current date) + (_d * days) + (_h * hours) + (_m * minutes))
else
set due date to (due date + (_d * days) + (_h * hours) + (_m * minutes))
end if
end if
end tell
end repeat
end tell
on error errMsg number errNum
display dialog errMsg & return & return & errNum buttons {"Cancel", "OK"} default button "OK"
end try
end run
on getSelection()
tell application "OmniFocus"
tell content of first document window of front document
set validSelectedItemsList to value of (selected trees where class of its value is not item and class of its value is not folder)
if (count of validSelectedItemsList) = 0 then error "No task(s) are selected" number -1000
return validSelectedItemsList
end tell
end tell
end getSelection