The Omni Group Forums

The Omni Group Forums (http://forums.omnigroup.com/index.php)
-   OmniFocus Extras (http://forums.omnigroup.com/forumdisplay.php?f=44)
-   -   select all in sidebar etc. (http://forums.omnigroup.com/showthread.php?t=13568)

Craig 2009-08-28 08:39 AM

select all in sidebar etc.
 
I'm trying to turn the "Exclude SALs from selection" script from this forum into something more automated to go into an Automator workflow, but I'm no scripting expert. Here's where I'm stuck:

(1) I cannot figure out how to applescript the selection of all items in the Omnifocus sidebar.

(2) What's the syntax for focusing on selected items?

(3) Also, is there a way to update ("take a snapshot of") existing perspectives via applescript?

Any help is appreciated!

Craig 2009-09-21 06:54 AM

bump.

curt.clifton 2009-09-21 02:39 PM

How about providing a link to the script in question? Some sample code or an indication of what you've tried or how you're approaching the problem would also be helpful.

The 'select' command should handle selecting the items, so that reduces the problem to generating a list of items to be selected. But it's unclear to me how selecting items is a useful thing in an Automator workflow. Can you describe the overall problem you're trying to solve? In general, people are more likely to offer scripting help if either the question is narrowly framed or they see how the overall solution might be beneficial.

Cheers,

Curt

whpalmer4 2009-09-21 03:54 PM

I believe I'm the author of the script he's attempting to modify. It is posted in this thread: [URL="http://forums.omnigroup.com/showthread.php?t=12955"]http://forums.omnigroup.com/showthread.php?t=12955[/URL] and the code for grabbing the list of stuff to process is essentially identical to the usual construction of your scripts, I think. It relies on the user having already selected something in the sidebar, and that's the part that the OP wants to script.

I don't think there's any Applescript support in OmniFocus for taking a snapshot of a perspective, though you could probably do it with UI scripting.

Craig 2009-09-21 06:14 PM

[QUOTE=whpalmer4;67208]I believe I'm the author of the script he's attempting to modify. It is posted in this thread: [URL="http://forums.omnigroup.com/showthread.php?t=12955"]http://forums.omnigroup.com/showthread.php?t=12955[/URL] and the code for grabbing the list of stuff to process is essentially identical to the usual construction of your scripts, I think. It relies on the user having already selected something in the sidebar, and that's the part that the OP wants to script.[/QUOTE]

That's exactly right. My apologies for insufficient explicitness.

The problem I'm trying to solve is this. (Re-reading whpalmer's link, I realize it's similar or identical to the situation user AmberV describes in the post immediately following the script in that thread.) I have my planning set up as areas-of-responsibility folders, each of which has projects and a "singletons" SAL. I also have an automator workflow that takes me step-by-step through my weekly review. It is mostly just confirmation boxes instructing me on each step, and simple applescripts that open iCal, appropriate OF perspectives, and so on.

One of the main steps in my weekly review is to review all my projects of course. To do that by hand I've found I can select all in the sidebar and run whpalmer's script (actually a modified one which also deselects folders), then hit Focus. If I want I could save this as a perspective, but it's not that useful because by the next weekly review I may have added a project which will then fall through the cracks if I don't go through the script filtering again.

So all of that is not terribly inconvenient to do, but I would like to be able to have my automator workflow do it for me. Thus my questions in the original post of this thread.

curt.clifton 2009-09-22 10:41 AM

Craig,

I get it now. That's a cool idea. Here's a script that will attempt to activate a named perspective, make sure project mode is selected, then select all projects excluding SALs in the sidebar. Activating the perspective seems a bit wonky, but the rest of it works fine. I don't plan to support this script, but hope you and others find it useful. Feel free to modify per the open license terms.

Cheers,

Curt

[CODE]
(*
This script selects all projects in the sidebar, but no single-action lists.

version 0.1, by Curt Clifton

Copyright © 2009, Curtis Clifton

All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

• Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

• Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

version 0.1: Original release

*)

property projectModePerspective : "Projects"

tell application "OmniFocus"
tell document window 1 of default document
set perspective name to projectModePerspective
set selected view mode identifier to "project"
if perspective name is missing value then
(* display alert "Unable to open a perspective named '" & projectModePerspective & ". Just switching to project mode with current settings." *)
end if
tell library of sidebar
set allTrees to every tree
my selectProjects(allTrees)
end tell
end tell
end tell

on selectProjects(theTrees)
using terms from application "OmniFocus"
repeat with aTree in theTrees
set treeValue to value of aTree
if (class of treeValue is project) then
set selected of aTree to not (singleton action holder of treeValue)
else if (class of treeValue is folder) then
set selected of aTree to false
set childTrees to every tree of aTree
my selectProjects(childTrees)
else
set selected of aTree to false
end if
end repeat
end using terms from
end selectProjects
[/CODE]

Craig 2009-09-22 12:06 PM

Awesome, thanks a bunch, Curt.


All times are GMT -8. The time now is 10:17 PM.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2024, vBulletin Solutions, Inc.