Text replacement triggered but not successfully executing (v9.0)

Hi everyone!

I'm excited to finally dig in to Keyboard Maestro. I'm going through the MacSparky field guide and everything is working perfectly, except for text replacement.

I'm hoping someone here can provide some insight as I'm unable to turn up any solutions on the web so far.

The issue

String replacement is successfully triggered. It seems like KM thinks the string replacement is happening successfully, but nothing is actually happening to text in my application.

My system

  • macOS Mojave 10.14.5
  • Keyboard Maestro 9.0

Things I've tried

  • Rebooting
  • Checking relevant things in the KM troubleshooting guide
    • In System Preferences, under Security & Privacy > Privacy > Accessibility: KM and KM Engine are enabled
    • Secure Input Mode doesn't seem to be an issue. I tried Onan's version of a script that detects that issue, but no apps are flagged as currently enabling secure input.
  • Quitting apps
    • Rocket (emoji app; keyboard watcher)
    • Paste (clipboard manager)
    • 1Password
    • Terminal
  • Stepping through with the KM debugger (it shows no error; looks like success)
  • Perusing ~Library/Logs/Keyboard Maestro/Engine.log (it shows no error; looks like success) [1]
  • Changing the trigger string (same result with any string)

^[1]: Example log output: 2019-08-18 14:25:55 Execute macro “Text replacement” from trigger The exact case string “;hw” is typed (then deleted)

Apps tested with

  • TextEdit
  • Apple Notes

Text replacement.kmmacros (1.4 KB)


Please let me know if there's any more information I can provide to clarify the problem :slight_smile:

It works for me (when I imported your macro). Testing now:

Hello, World!

Yup. I also tried other apps besides Safari.

Dang, if everyone posted detailed error reports like you, the world would be a better place. What are you, a professional software quality control expert?

That's the best I can do for now. But this info may be helpful.

1 Like

Aww, thanks Sleepy! I manage a developer relations team so I have a good idea what it's like to be on the receiving end of forum questions. :slight_smile:


Further thoughts on the issue...

I'm working with KM on a corporate machine, so I'm starting to wonder if there is some invisible IT magic blocking KM specifically from replacing text.

At the moment, I'm looking to see if Carbon Black Defense (aka Cb Defense) might be the blocker, though I'm just grasping at straws at this point.

You have a very simple KM macro which should work without any issues.
I have a number of very similar macros.

So there must be some app or utility that is blocking text expansion, like 1Password does when it is open. I'd suggest that you startup your Mac in Safe Mode, where all startup software is prevented from launching. Then start the KM Engine, and try your macro. If it works, then you will need to start-up the other items in your startup list, one-by-one, until you find the one causing the issue.

2 Likes

Playing around further, I'm starting to get the impression that any actions that manipulate input devices (keyboard, trackpad) are blocked somewhere on my system, seemingly at a level that KM is unaware of.

"Move and Click" also appears successful in KM, but doesn't actually seem to do anything.

On the other hand, things that are successful include:

  • Detecting typed text
  • Detecting mouse location
  • Button clicks (based on string parsing, not by setting mouse coordinates)
  • Window moves and resizes
  • Application activation
  • Notifications and alerts
  • etc etc

I could go on, but specifically I seem to be unable to drive keyboard and mouse input via KM.


Here are screenshots of KM's interactive help settings checker, showing that KM believes things are set up properly:

08 29

Nice suggestion @JMichaelTX. I'll give that a shot.

I'm seeing the same issue in Safe Mode. Very strange.

I may try installing a trial of TextExpander just to see whether the problem is specific to KM, or if it's generally an issue on my machine with apps that want to drive user input devices.

I seem to have stumbled upon the solution.

tl;dr

Even if KM Engine shows in System Preferences as enabled, and even if KM reports the Engine as enabled, in Mojave (and apparently Catalina?) you may need to remove KM Engine from System Preferences and re-add it.

How I stumbled upon it

Just for context, in case it's helpful.

I installed TextExpander and it was working fine, which really seemed odd. For some reason, that got me suspicious of the System Preferences security settings where KM was enabled (I knew that security settings in macOS have been getting finicky over the last several years).

I just decided to remove KM from the security settings and re-run KM's Interactive Help feature, which gave me the article linked above, which spells out the problem nicely.

Thanks to @Sleepy and @JMichaelTX for trying to help get to the bottom of this. Hopefully this thread will help someone later on.

Indeed, very strange -- I've never seen that.

Immediately after starting in Safe Mode, could you take a screenshot of your Sys Prefs > Users > your account > Login Items

You can also look in these folders for other startup items:

Launch daemons and agents

Since OS X 10.4 Tiger, Apple has given developers another mechanism for launching items automatically: launch daemons and agents, controlled by the launchd process. This approach provides more flexibility than either login items or startup items, but it is less transparent to users.

Behind the UNIX curtain: Instead of opening apps directly, launchd loads specially formatted .plist documents (XML preference files) that specify what should launch and under what circumstances. Sometimes these launch items run constantly in the background, sometimes they run at scheduled intervals, and sometimes they run as needed—for example, in response to an event such as a change in a certain file or folder—and then quit.

The .plist files that launchd uses can occupy any of five folders, and their location determines when the items load and with what privileges:

  • Items in /Library/LaunchDaemons and /System/Library/LaunchDaemons load when your Mac starts up, and run as the root user.

  • Items in /Library/LaunchAgents and /System/Library/LaunchAgents load when any user logs in, and run as that user.

  • Items in /Users/your-username/Library/LaunchAgents load only when that particular user logs in, and run as that user.

Keep your hands off of some: Of those five folders, the two located in the /System folder (/System/Library/LaunchDaemons and /System/Library/LaunchAgents) are for components included as part of OS X, and you should resist the temptation to remove or alter them—they’re essential to keep your Mac running correctly.

Good idea. Let us know how it goes.

1 Like

Thanks for this info! I'd have definitely done this but it seems I've stumbled upon the cause for my situation: I needed to toggle the KM Engine off and on again in System Prefs :slight_smile: I added some details to the thread.

Hopefully things are good at this point, but if I start noticing issues again, I'll have another look at login items and launch daemons.

And yet it still detected the “A” in the Interactive Help. Darn. So the system is screwed up enough that it will let Keyboard Maestro see the “A”, but not type an “A”. That is irritating. That is harder to test!

1 Like

Thanks Peter! I appreciate that this is a system issue, and likely very hard to work around. Just glad I got unstuck and could provide some info in the process.

I’m only a couple of days in and KM is already proving to be an amazing tool. Really excited to dig in further.

I have given up trying to detect the failure, and just report the possibility of it in the Interactive Help in the next version.