View Full Version : focusing on all non-single-action projects
Craig
2008-02-24, 08:46 PM
For my weekly review, I like to take a look at a list of all my active projects. Within my planning hierarchy, I also have interspersed some single-action lists ("teaching singletons," "husband singletons," "colleague singletons"), which I don't want to review in this part of my weekly review.
So my present practice is to show all active projects, select all, collapse all, then go through and deselect (with Command held down) the single-actions lists, and then hit focus to drop them out.
I'm wondering if this would be easily scriptable. Ideas on how?
RobTrew
2008-02-26, 10:41 AM
Something of this kind, perhaps.
tell application "OmniFocus"
tell default document
if number of document window is 0 then
make new document window with properties {bounds:{0, 0, 1000, 500}}
end if
end tell
tell window 1
set selected view mode identifier to "project"
set focus to {}
tell sidebar
select library
end tell
tell content
set lstFocus to {}
repeat with oTree in trees
set expanded of oTree to false
set oProject to value of oTree
if not (singleton action holder of oProject) then
set end of lstFocus to oProject
end if
end repeat
end tell
set focus to lstFocus
end tell
end tell
Craig
2008-02-26, 11:18 AM
RobTrew for President!
Thanks, that works. At first it didn't - I got an error about not being able to make something type boolean. But I realized it was because the inbox was selected in the preexisting window, so when the script selected the library it was adding to, rather than replacing that selection, and then the script seems to have choked on doing its business on the inbox.
Changing
set selected of library to true
to
select library
fixed that.
Very helpful! Thanks again - I learn lots from your scripts.
RobTrew
2008-02-26, 11:43 AM
Thanks for the edit. I will make it retrospectively.
Glad the snippet is useful.
Craig
2008-02-26, 11:53 AM
From your snippet I inferred that a good way to expand all would be this:
tell content of window 1
repeat with oTree in trees
set expanded of oTree to true
end repeat
end tell
but that leaves action groups collapsed. Is there a piece I'm missing?
RobTrew
2008-02-26, 12:06 PM
There may be a syntactic route to something more elegant, but here is an approach to doing it recursively.
tell application "OmniFocus"
tell content of window 1
repeat with oTree in trees
my Expand(oTree)
end repeat
end tell
end tell
on Expand(oTree)
using terms from application "OmniFocus"
set oSubTrees to trees of oTree
if (count of oSubTrees) > 0 then
set expanded of oTree to true
repeat with oSubTree in oSubTrees
Expand(oSubTree)
end repeat
end if
end using terms from
end Expand
vBulletin® v3.8.6, Copyright ©2000-2012, Jelsoft Enterprises Ltd.