Creating an Applescript for KeyBoard Maestro to launch Quick Capture even if Drafts not Open

I am new to Drafts but wanted to see if anyone had any ideas about this. I would like to be able to use a key-combination to open the Quick-Capture window of Drafts, even if the app is not running.

I found a similar Keyboard Maestro action which uses Applescript to do the same thing for the Quick-Entry panel of Omnifocus. You set the Keyboard Maestro key combination to the same key combination as is set for Quick-Entry in the OmniFocus app. So when you hit that key combination, it checks to see if OF is open; if so, that key combination opens Quick-Entry. If OF is not open, that Key combination launches OF and then the Quick-Entry window.

Script is below.

(* 
OopsieFocus

A script to launch OmniFocus and activate the Quick Entry Panel

By Shawn Blanc (http://shawnblanc.net)
May 20, 2011

With code used from the Toggle Twitter script by Red Sweater Software:
	http://www.red-sweater.com/blog/1646/toggle-twitter

Works great with FastScripts or Keyboard Maestro:
	http://www.red-sweater.com/fastscripts/
	http://www.keyboardmaestro.com/main/
	
How it works:
	Set this script to run using the same keyboard shortut that you use to launch the Quick 
	Entry Panel in OmniFocus. If you ever try to activate the Quick Entry Panel but 
	OmniFocus happens to not be running, then this script will launch OmniFocus and bring 
	up the Quick Entry Panel for you.
*)

set GTDAppName to "OmniFocus"
global GTDAppName
set GTDAppToUse to FindRunningGTDApp()
if (GTDAppToUse is null) then
	set GTDAppToUse to "OmniFocus"
end if

-- Is OmniFocus running?
on AppIsRunning(GTDAppName)
	tell application "System Events"
		return (count of (application processes whose name is GTDAppName)) is not 0
	end tell
end AppIsRunning

-- If OmniFocus is running, do nothing.
-- If OmniFocus is not running, launch it and bring up the Quick Entry Panel.
on FindRunningGTDApp()
	if AppIsRunning(GTDAppName) then
		null
	else
		tell application "OmniFocus"
			activate
			tell quick entry
				open
				make new inbox task
				tell application "System Events" to keystroke tab
			end tell
		end tell
	end if
	return null
end FindRunningGTDApp
type or paste code here

Does anyone have any advice on how to adapt this to Drafts, and its Quick-Capture window?

The best way to open capture is using the /capture URL. See example URLs below. I believe Keyboard Maestro has the ability to easily open a URL.

Open Drafts to quick capture…

drafts://x-callback-url/capture

Open Drafts to quick capture setting the initial text “TEXT”

drafts://x-callback-url/capture?text=TEXT

Wow! This is great. Thanks so much.

I disabled the shortcut in the app preferences, because otherwise, invoking my shortcut caused 2 quick-capture windows to appear. Deleting the in-app shortcut key-combination did the trick. Now, whether app is open or not, invoking my key-combination just opens 1 quick capture window.

If app is open, just the quick capture window opens. If app is not open, the app opens and the quick capture window is placed on top of it, ready to go!

1 Like