-
Notifications
You must be signed in to change notification settings - Fork 46
/
Copy pathLog completed item to OmniFocus.applescript
83 lines (63 loc) · 4.41 KB
/
Log completed item to OmniFocus.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
81
82
83
(*
# DESCRIPTION #
Creates a Completed task in a folder and project, with optional tag(s).
I keep a handful of these scripts that log to specific projects
# 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
- Updated for OmniFocus 3; supports adding 0 or many tags
2018-03-15
- Updated for compatibility with a breaking change in OmniFocus' AppleScript Dictionary
2015-05-19
- Initial version
# CONFIGURATION #
1. set myFolderName to the name of the folder containing your the destination project
2. set myProjectName to the name of the destination project
3. set myContextName to the name of the destination context
4. Save this script in a place that can be indexed by LaunchBar or Alfred
*)
property myFolderName : "Miscellaneous"
property myProjectName : "Ad Hoc"
property myTags : ["tag1", "tag2"] --set to empty list [] if you don't want to set tags
on log_item(myTaskName)
tell application "OmniFocus"
tell default document
set myFolder to (get first folder whose name is myFolderName)
repeat with thisProject in (flattened projects in myFolder)
if name of thisProject is equal to myProjectName then
set myProject to thisProject
exit repeat
end if
end repeat
tell myProject
set myTask to make task with properties {name:myTaskName}
mark complete myTask
tell application "OmniFocus"
tell default document
repeat with myTagName in myTags
set myTag to (first flattened tag whose name is myTagName)
add myTag to (tags of item 1 of myTask)
end repeat
end tell
end tell
end tell
display notification "\"" & myTaskName & "\"" & " logged to " & name of myProject
end tell
end tell
end log_item
on handle_string(mystring)
my log_item(mystring)
end handle_string
on alfred_script(q)
main(q)
end alfred_script
on run
tell application "OmniFocus"
activate
set mystring to text returned of (display dialog "Log in" & myProjectName & ":" default answer "Completed task description")
my log_item(mystring)
end tell
end run