show/hide Application extra functionality. e.g. with checkboxes:
[ ] only hide
[ ] only show
[ ] launch if not running
[ ] send [cmd+n] if no windows open
or, split up to multiple actions:
- hide application
- show application
- show application and launch if not running
- show application and launch if not running, or send [cmd+n] if no windows open
The first 3 of these can be easily accomplished with a small bit of shell scripting:
This one is technically AppleScript being run as a shell command:
osascript -e 'tell application "System Events" to set visible of process "Safari" to false'
Replace "Safari" with your app of choice.
Show App IFF it is already running
APP='BBEdit' ; pgrep -qx "$APP" && osascript -e "tell application \"$APP\" to activate"
Replace 'BBEdit' with your app of choice.
Launch App if Not Running
APP='Disk Utility' ; pgrep -qx "$APP" || open -g -j -a "$APP"
Note what the
-j arguments to
open will do:
-g Do not bring the application to the foreground.
-j Launches the app hidden.
Remove one or both if you do not want those features.
Also note that some apps do not respect
-j. These apps are to be considered to be of poor quality (often "cross-platform" apps which have not been given sufficient attention for their Mac port).
Send [cmd+n] if no windows open
I'm not sure how to do this one without Keyboard Maestro, but in Keyboard Maestro it would be simple:
- Activate 'App'
- Pause until 'App' is in the foreground
- If no front window, press ⌘N
Hi @tjluoma and thanks for the reply!
- I already have a script doing the first three (see below), all in the same script.
- As the logic behind what to do increases in complexity, it's easier to do this in a proper programming language than to expand on it with Applescript, whose syntax eludes me from time to time.
- Also, the "send [cmd+n] if no windows open" feature would be possible to create within btt (I think?) perhaps with a conditional activation group, it's a lot of work to do this for every single App I've customized (which is a long and ever increasing list)
- I'm pretty sure this functionality would be of use for many more than myself, and deserves to be native features of such a great app as BTT
I'm not sure exactly, but I think I got the zist of this script from Brett Terpstra.
set appName to "Typora"
set startIt to false
tell application "System Events"
if not (exists process appName) then
set startIt to true
else if frontmost of process appName then
set visible of process appName to false
set frontmost of process appName to true
if startIt then
tell application appName to activate
I will add more options to the "show/hide application" action soon.
Andreas, thanks for being 100% awesome!
I have added some of these options with the new versions. Would be great if you'd check whether they behave as intended.
I forgot to enable a feature to trigger a named trigger instead of cmd+n, which will allow more flexibility. I'll enable that with the next update.
- First feedback: It appears the triggers that already existed that used the "Show/Hide application" feature stopped working after this update; I had to re-edit this step in order to get it working again. I'm not sure how I can make a reproducible test case of this scenario on the drop of a hat.
- I will test this out thorougly once the update with cmd+n is released, will set off some time to tinker with my setup again at that time.
I just realized how I ended up with this awesome setup.
I bought "BetterSnapTool" and had some snall issues with it, and emailed you.
Got a free one year (I think) license for BTT !
After using ONLY the feature for moving/resizing windows with a regular mouse for over 6 months, I realized I wanted to duplicate the "hyper key" functionality I've been reading so much about.
Installed Karabiner_Elements, and enabled the hyper key
The rest is history!
Thanks for an awesome piece of software.