Here is a quick/ugly applescript I threw together that allows one to:
1. select multiple contexts
2. set all the filters
3. focus on a folder (or show all)
4. set or clear the search field
Just put in the values you want and save it with a meaningful name.
Some notes:
1. Applescript support for the sort fiter seems to be broken on Omni's end, so leave it blank for now.
2. Context selection is based on name-matching, so non-unique context names will only select the first instance.
3. Same for focusing on a folder
4. When onmi allows focusing on a project, more code will be required
5. There are a few calls to System Events, which is too bad, but what can you do.
6. I don't really know applescript well, so I'm sure there are parts that could have been accomplished better.
1. select multiple contexts
2. set all the filters
3. focus on a folder (or show all)
4. set or clear the search field
Just put in the values you want and save it with a meaningful name.
Some notes:
1. Applescript support for the sort fiter seems to be broken on Omni's end, so leave it blank for now.
2. Context selection is based on name-matching, so non-unique context names will only select the first instance.
3. Same for focusing on a folder
4. When onmi allows focusing on a project, more code will be required
5. There are a few calls to System Events, which is too bad, but what can you do.
6. I don't really know applescript well, so I'm sure there are parts that could have been accomplished better.
Code:
---------------------------------------------------------------------------- --Set smart parameters below. Empty strings leave existing setting. --context(s) property contextNames : {""} --a list of context names you want selected. -- *** if context names are not unique, only first instance will be selected *** --filter settings property contextGroupValue : "active-contexts" --choose from {"all-contexts","active-contexts"} property groupValue : "" --choose from {"none","context","due","start","competed","added","modified"} property sortValue : "" --choose from {"none","name","due","start","complete","add","modified"} -- *** sorting seems to be broken on Omni's end - leave it blank for now *** property taskStateValue : "" --choose from {"all","next","available","incomplete","flagged","complete"} property taskDurationValue : "" --choose from {"any","5m","15m","30m","60m","long","unestimated"} --folder/project to focus on. Use "All" to show all. property focusFolderName : "" --search Term. Use "Clear" to force-clear the search term. property searchTermValue : "" ---------------------------------------------------------------------------- global theWindow, theSidebar, theContent, foundFolder tell application "OmniFocus" activate -- set some variables set theDocument to document 1 set theWindow to document window 1 of theDocument set theSidebar to sidebar of theWindow set theContent to content of theWindow set selected view mode identifier of theWindow to "context" --make sure all contexts are expanded and deselected tell application "System Events" activate perform action "OOMakeFirstResponder" of outline "Sidebar" of scroll area 1 of splitter group 1 of window 1 of application process "OmniFocus" end tell activate tell application "System Events" perform action "AXPress" of menu item "Expand All" of menu "View" of menu bar item "View" of menu bar 1 of application process "OmniFocus" perform action "AXPress" of menu item "Deselect All" of menu "Edit" of menu bar item "Edit" of menu bar 1 of application process "OmniFocus" end tell --set selected contexts my selectContexts(theSidebar) --set filters if contextGroupValue is not "" then set selected smart group identifier of theSidebar to contextGroupValue end if if groupValue is not "" then set selected grouping identifier of theContent to groupValue end if if sortValue is not "" then set selected sorting identifier of theContent to sortValue end if if taskStateValue is not "" then set selected task state filter identifier of theContent to taskStateValue end if if taskDurationValue is not "" then set selected task duration filter identifier of theContent to taskDurationValue end if --set focus folder if focusFolderName is "All" then tell application "System Events" perform action "AXPress" of menu item "Show All Projects" of menu "View" of menu bar item "View" of menu bar 1 of application process "OmniFocus" end tell else if focusFolderName is not "" then if my selectFocus(theDocument) then set focus folder of theWindow to foundFolder end if end if --set search term if searchTermValue is "Clear" then set search term of theWindow to "" else if searchTermValue is not "" then set search term of theWindow to searchTermValue end if end tell on selectContexts(treeList) tell application "OmniFocus" repeat with thisTree in trees of treeList if contextNames contains name of thisTree then select tree (name of thisTree) of treeList with extending end if my selectContexts(thisTree) --recurse end repeat end tell end selectContexts on selectFocus(FolderList) tell application "OmniFocus" repeat with thisFolder in folders of FolderList if focusFolderName is name of thisFolder then set foundFolder to thisFolder as reference return true else if my selectFocus(thisFolder) then --recurse return true end if end repeat end tell return false end selectFocus