Toggling Apps With a Hotkey

I just put together a couple of handy Keyboard Maestro macros that I thought other users of this forum might find useful. I’m using KM, but anything that can assign a hotkey to run an applescript would work. It’s very simple, and very useful:

set appName to "Notes"

tell application "System Events"
	if visible of application process appName is true then
		set visible of application process appName to false
	else
		set visible of application process appName to true
		tell application process appName to set frontmost to true
	end if
end tell

I have one for Notes, and one for Terminal. The trick is to do a little setup beforehand and have the note or Terminal window (or what have you) open and in the spot you want it when you start running this script. For me, I’ve got a note named “Scratchpad” that I have open, the main Notes window closed, and the window set to float on top of everything else. Now when I hit the hotkey ⌘⌥⌃N the note appears and my keyboard focus moves to the window, ready to type. Then I hit the same hotkey to toggle it off and return to my previous window. Same for the Terminal.

Might be interesting to expand on this a bit, maybe setup an automated daily note, not sure, there are lots of options here.

6 Likes

Just wanted to share that there’s an ongoing discussion on an app I created specifically for this use case: https://talk.macpowerusers.com/t/rcmd-fastest-app-switcher-to-date

I had exactly the same need, to bring up the Terminal with a single key press, run a command or just check the status of a long running command and then press the same keys again to hide the Terminal.

Same thing with notes (I use NotePlan) for jotting things down fast or check a list of tasks.

rcmd has the Hide action that does just that. e.g. press Right Command - N to bring up notes, press it again to hide it. If Notes isn’t already launched, rcmd will launch it automatically.

I’m guessing you already have this nice workflow specifically adjusted to your needs, but I thought to share just in case you might like the adaptability of rcmd.

With it you don’t need to create a workflow for every app, it dynamically assigns keys based on your most used apps, and is also very easily customizable.

2 Likes

Nice! I’ll check it out.

1 Like