My most used AppleScript in OF1 no longer works. It looks like “Quick Open” would fulfill some of its functions, but this script searches both projects and tasks. Very helpful to call from Quickilver and have it search everything.
I was tinkering with it a bit last night to try and get it working again, but I’d love to have a hand if anyone else wants to pitch in.
Here’s a script I created for use with LaunchBar. If I remember correctly, QuickSilver uses a different handler, but changing the name of the handler shouldn’t be too hard. Please note that the script doesn’t search the inbox, because OmniFocus 2 can’t display the project list and inbox at the same time.
on handle_string(mystring)
tell application id "com.omnigroup.omnifocus2"
tell default document
set myWindow to make new document window
tell myWindow
set focus to {}
set selected sidebar tab to projects tab
set selected trees of sidebar to sidebar -- deselects everything
set selected smart group identifier of sidebar to "all-projects" -- deprecated, but works for now
tell content
set selected task state filter identifier to "all"
set selected task duration filter identifier to "any"
set selected task flagged filter identifier to "all"
end tell
set search term to mystring
end tell
activate
end tell
end tell
end handle_string
I made a few very minor tweaks, and I’m back in business.
on run
tell application id "com.omnigroup.omnifocus2"
activate
set search_term to the text returned of (display dialog "Search:" default answer "Enter search term")
tell default document
-- set myWindow to make new document window
set myWindow to first document window
tell myWindow
set focus to {}
set selected sidebar tab to projects tab
set selected trees of sidebar to sidebar -- deselects everything
set selected smart group identifier of sidebar to "all-projects" -- deprecated, but works for now
tell content
set selected task state filter identifier to "all"
set selected task duration filter identifier to "any"
set selected task flagged filter identifier to "all"
end tell
set search term to search_term
end tell
end tell
end tell
end run
FWIW, here’s a macro I created in Keyboard Maestro to do the same thing:
Command-2 (to open the Projects perspective)
Command-A (to make sure all projects are selected)
Alt-Command-F (to go to the Search field)
I’ve assigned this macro to F5 - I just hit F5 and I’m immediately in the search field, ready to search everything - as long as it’s assigned to a Project, and is not completed.
I adapt this to a second macro that searches Completed actions, simply by changing the first action in the macro to show me the Completed perspective instead of the Projects perspective.
I changed the script a bit, found it much easier to just make perspectives with the view options I wanted (with the GUI) and then have the script just activate that perspective.