Quick Open - System Wide Shortcut

Not a system-wide shortcut, but I use Launchbar and adapted @bmorgan’s script to take text from Launchbar and plop it right into Quick Open. It’s not super-fast (a half second), and you miss out on find-as-you-type, but it works if you know where you want to go.

    on handle_string(msg)
	
	
	tell application "System Events"
		tell process "OmniFocus"
			click menu item "Quick Open…" of menu "File" of menu bar item "File" of menu bar 1
		end tell
		keystroke msg
	end tell
	
end handle_string

Save it to ~/Library/Application Support/Launchbar/Actions/.

2 Likes

Is there ANY keyboard shortcut for Quick Open even within OF2? If so I can’t figure out what it is…

Look under “Edit” “File” in the OF menubar → ⌘O

1 Like

thanks for the tip! (it’s not under the edit menu though)

This is a great script. I’m not a scripting guru but have this working effectively through Keyboard Maestro. Is there any way after searching to bring Omnifocus to the front as the focused application automatically? This would make the script perfect.

UPDATE: Figured out how to do it, at least at the same time the Quick Open panel opens:

tell application “Omnifocus”
activate
end tell

Wow this is awesome - I did this with Alfred2 in seconds. I added a global shortcut key and used the following script:

on alfred_script(q)
  tell application "System Events"
    tell process "OmniFocus"
        click menu item "Quick Open…" of menu "File" of menu bar item "File" of menu bar 1
    end tell
end tell
end alfred_script
2 Likes

hey grant, sorry, not great at the alfred scripting - can you detail step by step process of creating the alfred script/workflow?

thanks in advance

@gtdwannabe I exported the workflow I created that binds “Option-Command-O” as a global hotkey. You can change this as you need. Also, you may need the powerpack. I’m using Alfred 2.3.

Link: https://www.dropbox.com/s/xp7tt3rhm8g9lxo/Omnifocus2%20Quick%20Open.alfredworkflow

Grant

2 Likes

Thanks for this script! I’ve hacked together a slight change to get it to switch to OmniFocus, too. I’m no AppleScript whizz, but it works for me:

on alfred_script(q)
    tell application "System Events"
        tell process "OmniFocus"
            click menu item "Quick Open…" of menu "File" of menu bar item "File" of menu bar 1
        end tell
    end tell
    tell application "OmniFocus" to activate the default document
end alfred_script

(The last line of the alfred script is the new bit.)

1 Like

Thanks! Works like a charm! Your update makes the script that much better.

1 Like

This is all terrific stuff and works well for calling OF from alfred from any application. Still not solving the open omnifocus when closed. I think with minimal work, we could get there.

Since I posted, I discovered Shawn Blanc’s Oopsie Focus (which I highly recommend). If we adapt shawn blanc’s scipt, I think this will wind up being quite a nice piece of team scripting here. I tried to figure it out myself, but lack the skills.

If you want to input text into the quick open text field, here’s the code. Would you guys mind if I packaged this into an Alfred Forum’s post?

on alfred_script(q)
    tell application "System Events"
        tell process "OmniFocus"
            click menu item "Quick Open…" of menu "File" of menu bar item "File" of menu bar 1
            set value of text field 1 of front window to q
        end tell
    end tell
    tell application "OmniFocus" to activate the default document
end alfred_script
2 Likes

Thanks, this works perfectly while OF is open. Do you know how to incorporate the oopssie focus script so that it works when it is not open?

Also, the script from this thread would be a candidate for similar treatment:

I’m thankful for the script development here. I took the lazy approach and installed Fastcripts which lets you assign global hotkeys to scripts (10 total in the free version). That way I have the hotkey set to the same quick capture combo I use when OF is open.

And the “One Click Search All” thread you linked was golden. Got those working as well and love searching in two steps from the keyboard.

1 Like

Have you done this yet? Could you post a link to this workflow? Thank you very much.

@gtdwannabe I’m not an Alfred user, but I just adapted Shawn Blanc’s OopsieFocus script to instead activate OF’s Quick Open panel if the app is closed.

You can set a global shortcut with Fastscripts per my post above, but the key difference between OopsieFocus and this script is that you do not want to make the script’s shortcut the same as OF’s Quick Open shortcut because of a conflict: system-wide, the CMD-O shortcut opens a file in its native app.

Therefore, either use the default shortcut when OF is open, and another one for this script; or, edit the script to remove the check on whether OF is running, and just force Quick Open with a new shortcut.

-- This script allows the opening of OmniFocus and a Quick Open panel using the Quick Open keyboard shortcut in OF in the event OF is not open.
-- If OF is open, nothing happens.
-- Launch using a launcher app with a global keyboard shortcut.
-- This is based on the OopsieFocus script written by Shawn Blanc

on appIsRunning(Omnifocus)
	tell application "System Events"
		return (count of (application processes whose name is Omnifocus)) is not 0
	end tell
end appIsRunning

if appIsRunning("OmniFocus") then
	null
	
else
	tell application "System Events"
		activate application "OmniFocus"
		tell process "OmniFocus"
			click menu item "Quick Open…" of menu "File" of menu bar item "File" of menu bar 1
			set value of text field 1 of front window to ""
		end tell
	end tell
	tell application "OmniFocus" to activate the default document
end if

FWIW, you can do this with no scripting in Keyboard Maestro.

1 Like

In BetterTouchTool:

2 Likes

Goodness! I didn’t even know BTT could do that! There go a few minutes tinkering…

@derekr’s script didn’t quite work for me, but this slightly modified one does:

on handle_string(msg)
	tell application "System Events"
		tell process "OmniFocus"
			click menu item "Quick Open…" of menu "File" of menu bar item "File" of menu bar 1
			set value of text field 1 of front window to msg
		end tell
	end tell
	
end handle_string