Warn Before Quitting Macro

I have my thumb on the Command key most of the time. I work with shortcuts to switch between apps, trigger Alfred workflows, and run Keyboard Maestro macros to save time. I also prefer to quit unused apps immediately, so pressing Command + Q has become my second nature. Sometimes I stupidly quit the apps that run important tasks — duh!

Warn Before Quitting Keyboard Maestro Macro

Google Chrome has a neat feature called “Warn Before Quitting” to warn us if we try to quit the browser with some active tabs running. This feature could have saved me from potentially ruining the in progress tasks that I used to run in Terminal, or pause the playing song in Spotify. Most of the time, I want to enable this feature for few selected apps.

I couldn’t find any apps that boast “Warn Before Quitting” feature, so I decide to build my own small utility in Keyboard Maestro. The macro acts exactly like the one in Google Chrome where you can customize the notification message and the elapsed time needed to confirm quitting the apps.

Installing Warn Before Quitting Macro

Download the Warn Before Quitting Macro and import to your Keyboard Maestro library. If you haven’t heard about Keyboard Maestro before, it’s a powerful utility to simulate user interaction through macros with a dozen of access to environment variables.

Choose Warn Before Quitting Macro Apps

Choose Your Apps. You trigger the macro by pressing Command + Q. If you’re like me, you certainly don’t want this behavior for every application you use. The macro lets you decide which application should run this macro. Simply add the application to the list to enable this macro for the app.

Set Warn Before Quitting Macro Pause Time

Configure Elapsed Time. The default time is 0.2 seconds, but you can change to any value you prefer.

Customize Warn Before Quitting Notification

Customize The Notification. Keyboard Maestro supports Growl and Notification Center. It lets you easily choose which one you want to use by toggling them in the editor panel. Also, for you who want to customize the message, you can do it right from each notification text field. The %Application%1% variable displays the front window application name.

How It Works

Keyboard Maestro is such a versatile utility because it allows anyone to build powerful macro with a small amount of efforts. You can create a macro by recording your actions, or you can put your programmer cap and come up with an algorithm for your macro.

Here’s how the Warn Before Quitting Macro works:

First, I assign Command + Q as the hot key to trigger this macro. The macro will assign a variable that lets you decide how long it takes to confirm quitting the front application.

There is only one condition we need to check: the front application. Since we only want selected apps to have this “warn before quitting” feature, we will include any apps that we want to protect in the This application is at the front as part of the matching conditions. Matching apps will show notification, and the macro will check whether both Command + Q are still pressed after elapsed pause time.

As for the rest of apps that are not part of the matching conditions, the macro will quit the front application without warning.

This is the ideal way to create a macro that is made to run in few selected applications, and to maintain a normal function in excluded applications. For example, we want to keep the quit feature without warning in applications that are not part of the list.

I have been using this macro for a year, and I’m sure I can’t live without it. If you decide to tap deeper into this macro, I highly recommend that you check out some of the posts I wrote before in the related posts below.

Download Warn Before Quitting Macro