-
Notifications
You must be signed in to change notification settings - Fork 46
/
Copy pathAppend Note to Selected Task.applescript
80 lines (60 loc) · 2.11 KB
/
Append Note to Selected Task.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
(*
# DESCRIPTION #
Appends a note to the selected OmniFocus task(s).
- By default, the clipboard contents are used for the note
- If triggered from LaunchBar or Alfred, you can specify the text
See https://github.com/dbyler/omnifocus-scripts for updates
# LICENSE #
Copyright © 2015-2020 Dan Byler (contact: [email protected])
Licensed under MIT License (http://www.opensource.org/licenses/mit-license.php)
(TL;DR: no warranty, do whatever you want with it.)
# CHANGE HISTORY #
2020-02-14
- Purge old Growl code; general cleanups
2017-04-23
- Fixes an issue when running with certain top-level category separators selected
- Minor update to notification code
2015-05-17
- Fix for attachments being overwritten by the note
- Use Notification Center instead of an alert when not running Growl. Requires Mountain Lion or newer
2015-05-09
- Original release
*)
property showNotification : true --if true, will display success notifications
on main(q)
if q is missing value then
set q to (the clipboard)
end if
tell application "OmniFocus"
tell content of first document window of front document
--Get selection
set validSelectedItemsList to value of (selected trees where class of its value is not item and class of its value is not folder and class of its value is not tag and class of its value is not perspective)
set totalItems to count of validSelectedItemsList
if totalItems is 0 then
display notification "No valid task(s) selected" with title "Error"
return
end if
if totalItems > 1 then
display dialog "Multiple items selected. Continue?" buttons {"Cancel", "OK"} default button 2
end if
repeat with myTask in validSelectedItemsList
tell myTask
insert q & "
" at before first paragraph of note
end tell
if showNotification then
set alertTitle to "Note added to " & name of myTask
set alertText to "\"" & q & "\""
display notification alertText with title alertTitle
end if
end repeat
end tell
end tell
end main
main(missing value)
on alfred_script(q)
main(q)
end alfred_script
on handle_string(q)
main(q)
end handle_string