Skipping an action in the presence of a text-substitution bubble

Need a macro that would execute an action except when there is a text substitution bubble present on the active or fore-most window.

Welcome to the forums ... I have a couple questions on your question :).

By "text substitution bubble," do you mean one of these things?


If not that, then what are you referring to?

And either way, I'm also confused by "would execute an action except when there is a text substitution bubble present..." Does that mean this macro is always running, doing something, and it needs to not do that thing when one of those bubbles appears? An always-running macro would be a big CPU hog.

Or do you mean you want to manually trigger a macro (by shortcut or typed keys or whatever), and then have it test to make sure there aren't any text substitution bubbles onscreen before it does anything?

In many cases, it helps us help you if you can describe what it is you're trying to accomplish, rather than a description of a portion of the problem at hand. What are you trying to do with this macro, and why is it important to detect the substitution bubbles?


Yes this is the bubble, you have it right.
Yes, a manually triggered macro by a hot key and the action is type a keystroke.
If there is a bubble anywhere on the active window, the macro should not execute.
Thank you.

The only way you might (with extra emphasis on might) be able to do this is with an If/Then and a Found Image check, something like this:

The problem, though, is that what you see there—the small 'x' in a squared circle—is the only unique thing you could maybe use to identify the bubble. And it's so light and gray that there's a very fine line between Keyboard Maestro being able to find none of them, and thinking everything's a bubble.

In my testing, moving the "fuzziness" slider around, I couldn't find a setting that would find just the actual bubble. At a level where it can see the bubble, it thinks everything is a bubble, so there are lots of false positives. If I try to make it less fuzzy, then it can't see the bubble even when it is onscreen.

And you can't look for the full bubble plus word, obviously, as the word(s) will change every time.

Maybe @Airy has some better ideas; they really grok the Found Image stuff much better than do I, but I just don't see how you're going to find a distinct-enough image to reliably capture the bubble, but only the actual bubble. Maybe, in theory, there's some macOS process that starts and stops only when the bubble is present, but I'm not sure how you'd figure out what that process name is to look for it.

In short, I'm stumped; I don't know this one is doable.


Again thanks for your help. I was going to try the macro you show below but can not find the first line,
{} If all conditions…

If you still have the macro depicted below, pls send it to me.
Thanks, John

The first step is just an If-Then action, with the Found Image condition, and it's attached:

If Then Else Action (v11.0.2)

If Then Else.kmactions (9.1 KB)

However, you have to capture the image yourself—using the one in the attached will definitely not work (due to how Keyboard Maestro stores the images, I believe).

To capture the image, use Shift-Command-Control-4, drag out a region around the bubble, and then release. It's now on your clipboard. Paste into an image editor where you can trim it down, and then copy it from there and paste it into Keyboard Maestro.