And here is one to put everything back to default:
Code:
-- set parameters
set contextGroupValue to "active-contexts"
set groupValue to "none" as text
set sortValue to "none" as text
set taskStateValue to "incomplete" as text
set taskDurationValue to "any" as text
set searchTermValue to "" as text
set focusFolderValue to null
tell application "OmniFocus"
activate
set theWindow to document window 1 of document 1
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 the filters
set selected smart group identifier of theSidebar to contextGroupValue
set selected grouping identifier of theContent to groupValue
(*uncomment this when the bug is fixed
set selected sorting identifier of theContent to sortValue
*)
set selected task state filter identifier of theContent to taskStateValue
set selected task duration filter identifier of theContent to taskDurationValue
--set focus folder and search term
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
--set focus folder of theWindow to focusFolderValue
set search term of theWindow to searchTermValue
end tell