Idea: Pause KM Engine Action & Menu Bar Option

Hi,

Might be a stupid idea, but I didn't find an easy way to temporarily disable or pause the KM engine.

I have some macros that automate things with global triggers, e.g. map shares when connect to specific networks or disable WiFi when a thunderbolt network interface connects. In certain circumstances, it would make sense to temporary disable those. Yes, I could just disable the macro group where they are in, but they might be scattered across different ones or one could be not aware of all of them. So it could be helpful to just globally disable everything and then enable it again.

Just to clarify: I already have a working solution, but I feel this could be helpful as a general out-of-the-box KM feature (KM action and an option for the menu bar icon maybe).

Julian

Obviously, the KM Engine has to be running in order to execute any macro. So we can’t use a KM macro to start the KM Engine.

I’m pretty sure a script could be written to stop the Keyboard Maestro Engine process, and then another script to start it, but I’m not sure how off the top of my head.

Maybe Chris (@ccstone) can help out here. :wink:

Stopping the engine seems entirely feasible through a macro; the real issue, as you say, is starting it again. Fortunately, the solution is very easy; on a standard install where KM is located in the root Applications folder, this simple shell script will work:

open "/Applications/Keyboard Maestro.app/Contents/MacOS/Keyboard Maestro Engine.app"

It’s easy to store as a snippet in an app like Typinator and run it from Terminal or a launcher like LaunchBar or Alfred, or even to make a custom action/workflow for the latter two options. I did just that for Alfred, and showed how to do so here.

Yeah, you guys are totally right. Didn’t even think of that :slight_smile:

As I said, I have a solution: All those macros are in one macro group and I just disable that group. Works for me, but I feel like it should be a KM standard feature to pause the engine through the menu bar item.

The macro would work if the activate/deactivate macro group had a “all groups except this one” option or if could activate/deactivate smart groups.

Could be a handy feature. That is all.

Hey Guys,

----------------------------------------------------------------
# Auth: Christopher Stone
# dCre: 2018/04/20 09:54
# dMod: 2018/04/20 09:55
# Appl: Keyboard Maestro Engine
# Task: Quit and restart the Keyboard Maestro Engine
# Libs: None
# Osax: None
# Tags: @Applescript, @Script, @Quit, @Restart, @Keyboard_Maestro_Engine, @Engine
----------------------------------------------------------------

tell application id "com.stairways.keyboardmaestro.engine"
   if running then
      quit
   else
      launch
   end if
end tell

----------------------------------------------------------------

This sort of thing is a good reason to have FastScripts on your system – even the free version which has unlimited menu scripts and 10 available keyboard shortcuts. (For $9.95 U.S. you get unlimited global and app-specific keyboard shortcuts.)

I currently have 25 AppleScripts that drive the Keyboard Maestro Editor in various ways, and they’re all in FastScripts – because I don’t want Keyboard Maestro driving itself – particularly since its dead in the water when the engine isn’t running.

I need a number of my scripts to work when the KM Engine is not running,

There are many other advantages.

  • Testing AppleScripts using a different run mechanism.
  • Offloading long-running processes that reduce performance of the other app.
  • More I can’t think of pour le moment.

I’m still using it alongside Keyboard Maestro 15 years after I bought it, because there’s synergy having both – and that lets me get more work done.

I feel the same way about Typinator. Although Keyboard Maestro will do most of what Typinator will do (albeit a little more awkwardly), Keyboard Maestro can’t do text-expansions in its own running UI Actions – Typinator can – and vice versa.

Once again there’s good synergy between the two utilities.

-Chris

6 Likes

Thanks, Chris. I had a feeling you would have a great script for this.

To All:

Here’s a minor mod of Chris’ script to give you a notification so you know for sure which action has been taken:

tell application id "com.stairways.keyboardmaestro.engine"
  if running then
    quit
    set msgStr to "STOPPED."
  else
    launch
    set msgStr to "STARTED."
  end if
end tell

set msgTitleStr to "Toggle KM Engine On/Off"
set msgStr to "KM Engine has been " & msgStr
display notification msgStr with title msgTitleStr sound name "Tink.aiff"

1 Like

Hey JM,

That's a good idea.

Although for me the Status Menu stands out enough it's not necessary.

I also use the “Iconaholic Loud” icon style:

07

Because it makes VERY sure I know when macros are running.

It saved my bacon once when I noticed a macro was running longer than it should – a shell script macro, which I promptly killed – using my global Kill-All-Macros keyboard shortcut.

K

That saved me from scragging my whole downloads folder.

-Chris

Another good reason for doing this is to temporarily quit the KM engine in order to enter a special character (like u-umlaut, for example) by using a key combination (like option-u in the case of umlaut) that might otherwise be assigned to a KM macro.

Hey @thoffman666,

That seems a bit drastic.

Why not just create text-substitution macros to handle any oft-used umlauts?

-Chris

In my case, that’s even more work (and more to remember) than occasionally pausing the engine. If I were typing umlauts and the like on a daily basis, it might be different. My point is that whenever a key combination is needed for something (whether for text or anything else), but it’s unavailable because of using it as a trigger in KM, it’s nice to be able to pause the engine.

I get your point.

Just keep in mind that this is not a convenient pause — it’s fully quitting the engine.

It quits and restarts pretty fast, so this is not that big a deal — but that’s why I used the word “drastic”.

-Chris

I agree with you on that. That’s why I would prefer an actual pause function in KM, as was available in QuicKeys.

Make a feature request to Peter.  :wink:

-Chris

Noted.

1 Like

I was just about to ask about this when this was helpfully listed as "similar to" my post. And I have the same reason—I have a (inherited) macro assigned to Opt+3 because being in the colonies I never need a pound sign. Until I needed a pound sign today. :slight_smile:

So, another vote for a menu item to pause (not quit) the KM engine, preferably a toggle, so we could use the same (Mac, not KM) hotkey to turn it on or off. (Even if KM didn't assign a hotkey, we could assign one to the menu item via the Mac Keyboard Shortcuts.)

1 Like

You can easily stop, start, and toggle the KM Engine now.
What difference or advantage to you see in "pausing" vs a stop/start?

You can easily stop, start, and toggle it how? I don’t see any references to any of those, either, or anything on the menus.

Sorry, I intended to provide this link but didn't:
TIP: How To Launch or Restart KM Engine Without Using KM

Restart, Start, not pause. And create an AppleScript or three. And assign shortcut keys to them.

My ditto of the previous request stands.

Where are you thinking of a menu item? Do you mean something like a Pause Engine menu item in Keyboard Maestro Editor? If that, you could use Keyboard Maestro (or System Preferences) to assign a shortcut to File > Quit Engine and also add a shortcut in System Preferences for File > Launch Engine (the same shortcut will work assigned to both). Even so, the KM Editor would need to be frontmost, so that makes me uncertain I'm understanding.

Or a menu item somewhere else?

If you don't want to make it so the KM Editor needs to be open, you could do it with a KM macro that executes an AppleScript, activated with a hot key or other KM trigger. This script will quit the KM engine then relaunch it after a preset delay (in the script, change the delay to whatever number of seconds you'd like from the number shown of 30 seconds):

tell application "Keyboard Maestro Engine"
   quit
   
   delay 30
   
   tell application "Keyboard Maestro Engine"
      activate
   end tell
end tell