Hot Key Only Works when KM Editor Open

I apologize if I’m posting this in the wrong place. I also did search the forum for a similar previous post.

I have a macro configured to use the Control+A shortcut. Pressing that hot key used to work at any time. Suddenly, in the last couple of weeks, it only works while the Keyboard Maestro Editor is open, not when it’s closed. The Engine is running, and other macros fire just fine.

The macro group it’s in is configured as Available in All Applications, Available in All Windows, and Always Activated.

Keyboard Maestro v. 7.0.3, Mac v. 10.10.5

Thanks

Troubleshooting - Macros Not Firing

Whenever a macro does not fire when expected, the troubleshooting process is the same (as described on the wiki Troubleshooting page).

Here is what to do:

  • Ensure the Keyboard Maestro Engine is running - the Keyboard Maestro status menu should show in the menu bar on the right hand side (unless you’ve turned it off).
  • Ensure you have accessibility enabled (click on the status menu and Keyboard Maestro will tell you if there is a problem).
  • Ensure the Macro Group is enabled, and is active in the application in question.
  • Ensure the macro is enabled.
  • Ensure the macro actions are enabled.
  • Add a status menu trigger, and verify that the macro is active by checking for its name in the Keyboard Maestro status menu.
  • Add a Display Text action to the macro to verify that the macro is firing.
  • Choose Start Debugging from the Status Menu, ensure Pause New Macros is turned on, and trigger the macro. Step through the actions to see where it is going wrong.

Basically, you have to discover if the macro is active, if the trigger is firing, or if the actions are failing.

If you still cannot figure it out, post your macro.

Thanks.

It looks like it might have been cache issue. I tried all of the above, but what fixed it was wiping out application caches.

I’ve saved the troubleshooting page URL for future reference, though.

It seems the problem is that my Keyboard Maestro shortcuts conflict with the system shortcuts. Ones like Control-A and Control-T, for instance. Sometimes they fire the KM action; sometimes they fire the default system action.

I had thought KM would override the system shortcuts. Keyboard Maestro and Keyboard Maestro Engine are active in Security & Privacy > Accessibility.

Is there a way to force KM to always answer shortcuts?

See: What is the difference between different kinds of hot keys?

Hot Keys will override menu shortcuts. But Hot Keys are shared by all applications and each applications’ hot keys will all trigger. And then there are event tap keys, which are unusual and can potentially override everything (mostly this is just Command-Tab).

It’s something else. I’ve submitted a support request.

I am having the same problem. Everything works when KM’s editor is open and everything works fine following the steps for debugging - because debugging requires KM’s editor to be open too.

My problem occurs with Sketch and a SHIFT + CMD (⌘) + Right Arrow shortcut.

If I open KM’s editor and close KM’s editor the shortcuts start working again in Sketch for a short time, but then they stop working. Sometimes, Sketch ignores the keystroke entirely, other times, Sketch does something different than what the shortcut is supposed to do.

Every find a solution to this @iampariah?

You don't need the editor open to debug things.

You can look in the Engine.log file to see any triggered macros (~/Library/Logs/Keyboard Maestro). You can get to ~/Library in the Finder by holding down the option key and selecting Library from the Go menu.

You can see the Keyboard Maestro status menu in the menu bar (which tells you Keyboard Maestro Engine is running).

You can start debugging from the Keyboard Maestro status menu.

You can add Log messages to your macro (and then quit the editor) to see more information from your macro when it runs.

I am still having this problem, but the trick is, if Keyboard Maestro is given any type of focus, the bug goes away and the macros start working again.

It takes a few hours, sometimes a day for the bug to come back after giving KM focus. I would have to start debugging as soon as it starts working and wait for it to stop working, which may not be ideal?

Here is a demo video, including key presses before and after giving KM focus and closing it:
https://vimeo.com/262881462

Here is the log file for today:

2018-04-02 10:00:04 Running application query took a while (15918 us)
2018-04-02 11:17:31 Running application query took a while (22225 us)
2018-04-02 13:49:26 Running application query took a while (3687 us)
2018-04-02 15:10:03 Running application query took a while (12575 us)
2018-04-02 15:10:16 Running application query took a while (5729 us)
2018-04-02 15:10:18 Running application query took a while (5327 us)
2018-04-02 15:10:37 Running application query took a while (7004 us)
2018-04-02 16:51:07 Running application query took a while (9361 us)
2018-04-02 16:51:26 Editor Quitting

That log is what you can see in Demo.

It looks like the macros are inactive.

So there are a couple questions to ask:

Can you repeatably cause it to happen?

If the macros were global, do they work? Maybe make a copy of one of the macros and move it to the Global Macro Group, and give it some unique hot key. Then when it fails, see if that works.

What does Keyboard Maestro think is the front application at this point? Make a macro that displays %Application%1%.

Q: Can you repeatably cause it to happen?
A: It happens on it's own, after a few minutes, KM seems to stop working. Giving KM focus makes it start working again for a few moments, then it stops working again & the native shortcuts take over.

Q: If the macros were global, do they work? Maybe make a copy of one of the macros and move it to the Global Macro Group, and give it some unique hot key. Then when it fails, see if that works.
A: They mayors were in a Sketch folder, which I have now disabled, and copied all of the macros into the "Global Macro Group" folder in KM. I will see how it goes.

Q: What does Keyboard Maestro think is the front application at this point? Make a macro that displays %Application%1%.
A: I think you are saying to make that macro, then run it whenever KM quits again. I will try that. I am not sure how to make a macro that does that, but will try to figure it out. The shortcuts are supposed to work when Sketch is the front/focused app, which is always the case when the shortcut were failing.

I've attacked a few screen grabs o the previous Sketch-speciic macro setup in KM.

It's very easy. @peternlewis gave you the answer:

So, create a new Macro in the Global Macros Group, and put the token %Application%1% in the Display Text in a Window action, like this:

image


Here's a better diagnostic macro. It will display:

  1. Front app
  2. Front window
  3. Last 100 lines in the KM Engine log

As soon as the issue first occurs, then trigger this macro.
I have set a trigger of ⌘⌃⌥F, but you can, of course, change it.

If you cannot resolve your issue from this data, then copy all of the data in the Display Window, and paste here in a code block (see instructions at bottom).


MACRO:   Display Front App and Window


#### DOWNLOAD:
<a class="attachment" href="/uploads/default/original/3X/1/a/1a113c85199358ad77f8f091f4262e62c1b391d0.kmmacros">Display Front App and Window.kmmacros</a> (4.8 KB)
**Note: This Macro was uploaded in a DISABLED state. You must enable before it can be triggered.**

---



![image|458x999](upload://6pljE2ScQmvfRO9Z1aO8ZQKsGHE.jpg)

---

### How to Put Code (or Text) in a Forum Code Block
Just insert your text between the lines with the triple backquotes:

![image|167x65](upload://pyC3ZpMo4qXPNkOrhB7dJFwNSD3.jpg)

See [Markdown for Code Blocks](https://help.github.com/articles/creating-and-highlighting-code-blocks/#syntax-highlighting)

To get syntax highlighting, then use the keyword in lower case for that language, like:
`applescript`
`javascript`
`html`

Here is a macro that will paste the script on the clipboard into the forum in the proper format:
#### [MACRO: KM Forum -- Paste Script Block](https://forum.keyboardmaestro.com/t/paste-script-block-in-km-forum/4047)

So far, since moving the Sketch macros into the Global Macro Group, I have not experienced the problem initially reported. That said, I have had KM editor open the whole time, which usually keeps macros working.

Quitting the KM editor now and have the “Display Front App and Window” macro ready to capture any data I can if the problem comes back.

Curious what it would work in Global and not in a Sketch macro?

OK, KM is working if the Sketch macros are set to global, but that is causing interference with other shortcuts.

Is there a way to get the macros to work just as well when in an Application-Specific macro group?

Yes, as long as the macro group is actually active in the target application.

It sounds like the macro group is not active in Sketch. Maybe the Sketch is doing something odd (like launching and then quitting and launching some sort of sub-application (games sometimes do this, but maybe Sketch is too).

Do you think this would be visible in some sort of log file somewhere?

Sketch does have a model to run plugins, and I have plenty of plugins running.

You can perhaps see what processes are running using the ps command in the Terminal.

What I would try would be this:

  • Set the Macro Group to be active in some other application (eg Safari or Mail or whatever).
  • Quit the Keyboard Maestro editor.
  • Launch Sketch and let it sort itself out
  • Launch Keyboard Maestro
  • Set the Macro Group to be active in Sketch from the popup menu. At that point, with Keyboard Maestro freshly launched, it should only list the running applications, and so hopefully that will properly target Sketch.
  • Use the Assistance window to verify whether the macro / macro group is active when Sketch is at the front.
1 Like