-
Notifications
You must be signed in to change notification settings - Fork 28
/
Set-Duration.applescript
39 lines (31 loc) · 1.05 KB
/
Set-Duration.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
use AppleScript version "2.4" -- Yosemite (10.10) or later
use scripting additions
use kl : script "Kevin's Library"
on run argv
try
if class of argv = script or class of argv = document then
set duration to "90" as number
else if class of argv = list then
set duration to (item 1 of argv) as number
end if
tell application "OmniFocus"
set selectedItems to my getSelection()
repeat with t in selectedItems
tell t
set estimated minutes to duration
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