forked from dbyler/omnifocus-scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFocus in New Window.applescript
81 lines (63 loc) · 2.19 KB
/
Focus in New Window.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
(*
# DESCRIPTION #
Opens the selected task's project in a new window so you can jump from a context
perspective view into the project without losing place.
(Also works with multiple items selected)
# LICENSE #
Copyright © 2015-2017 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 #
2018-11-28
- Updated to work with OmniFocus 3
2017-04-23
- Fixes an issue when running with certain top-level category separators selected
2015-04-28
- Initial release
*)
on main()
tell application "OmniFocus"
set myFocus to {}
-- get selection
tell content of front 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 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
my notifyWithoutGrowl("No valid task(s) selected")
return
end if
repeat with validSelectedItem in validSelectedItemsList
validSelectedItem
if (containing project of validSelectedItem) is not missing value then
set end of myFocus to (containing project of validSelectedItem)
else if (assigned container of validSelectedItem) is not missing value then
set end of myFocus to (assigned container of validSelectedItem)
end if
end repeat
end tell
-- no valid projects to focus on
if length of myFocus is 0 then
my notifyWithoutGrowl("No projects to focus")
return
end if
-- make new window
tell default document
make new document window with properties {perspective name:"Projects"}
end tell
-- set focus
tell front document window of front document
set focus to myFocus
end tell
-- ignoring application responses
tell application "Keyboard Maestro Engine"
do script "B57A8FB4-0D76-43B0-8F76-928C84694E66"
end tell
-- end ignoring
end tell
end main
on notifyWithoutGrowl(alertText)
try
display notification alertText with title "OmniFocus Script Complete"
end try
end notifyWithoutGrowl
main()