Macro Works Great - But Only When App *not* Focus

Hi!

I am trying to assign a hot key to a menu bar item that has no title, only an image. If I do not have the target application focused, the macro happily finds the image. If I do nothing more than click the application to focus it, the macro no longer works. Nothing in the screen arrangement has changed, it still looks exactly the same, except the bar at the top of the target application is now filled in with blue, indicating it is the active application.

The other macros I have continue to work just great. They aren't trying to find an image, they are just firing up applications, so, not quite the same, but it means at least that the macro keystrokes are getting through to KM.

I'm not really sure what to try now. The application I want to target is called "Atticus" and is a progressive web application.

Check this out - when I put the debugger in, it never triggers, even if it is before the "find image" part. But other macros I have work just fine - I have several that open up different applications - they work great even under the same window as front focus. The debugger fires up and everything.

So how could the "find image" affect something that occurs in the step before it? Why wouldn't the debugger fire? I've tried several different hotkey combinations, verifying that they aren't colliding.

I'm so confused!

Can you post the macro so we can look at it? Select the macro, click the Share button, select Share to Forum. When the new post opens, select the text, copy/cut it, cancel the new post, and then paste it here as a new message.

-rob.

Atticus - Add Image.kmmacros (4.6 KB)

also, I knew I was supposed to do that. Apologies. thanks for reminding me.

Is the macro actually triggering? You can put in a "Display Text" as the very first action in your macro to check, or look at the Engine log (~/Library/Logs/Keyboard Maestro/Engine.log) in the Console app to see if the macro executed.

PWAs often capture more keystrokes than you'd think, so it might be snaffling your hot key before the KM Engine sees it.

and with respect to the "target" - I've tried a couple different things, they all worked when Atticus wasn't activate... This just happens to be where things are when I posted it.

oh, it's totally not triggering. That's what I'm trying to sort out.

But - and this is what is killing me - why the heck would my other macros trigger? They all work perfectly fine - it's just this one!

and this is after shuffling around the keystrokes that are being used to trigger it. I'm going to go look at the logs now.

I think the problem is likely related to the conditions on your Group settings. Remove the condition:

image

...and it will probably work. I hope. At least a 50% chance it will work. If it works, I won't try to explain it because I don't fully understand it.

Do they trigger when Atticus is frontmost?

And try removing the window name condition from your Macro Group so that the macro is available in all windows -- it may be that Atticus is doing something funky with the title display, adding in "Atticus" when that isn't the actual window name.

ok, so, the macro isn't triggering at all if the atticus window is in the front. never starts, never hits the debugger. If I move at least one window in front of it, it triggers just fine.... Let me try a bunch of stuff.. I tried the "name in window" thing before, but let me be more methodical...
You know, something is just woooonky.

I'm going to do what I should have done a while ago and just start a brand spanking new macro.

Will report back :slight_smile:

Ok! I built a totally new macro. Something was corrupted with that one, so, now I can get it to trigger (yay!)

This is my new macro:

But! It won't find the image. Now, this is interesting in how it is failing to find the image -

the first two were me using "find in front window" as the area in which the macro should look. Then I changed it to "all screens".

It looks like the PWA content is somehow behind a wall - look at these log entries:

2025-03-31 12:18:37 Action 5496 failed: Click at Found Image failed with error failed to capture front window
2025-03-31 12:18:37 Click at Found Image failed with error failed to capture front window. Macro “Atticus Image” cancelled (while executing Move Mouse to (0,0) from the Center of the Found Image).
2025-03-31 12:19:05 Execute macro “Atticus Image” from trigger The Hot Key ⌃⌥⌘Z is pressed
2025-03-31 12:19:14 Execute macro “Atticus Image” from trigger The Hot Key ⌃⌥⌘Z is pressed
2025-03-31 12:20:06 Action 5496 timeout exceeded. Macro “Atticus Image” cancelled (while executing Move Mouse to (0,0) from the Center of the Found Image).

So is the underlying problem that this is one of those cussed applications that “live in the menu bar”? If so, you might be able to activate it by something like this in an Execute Applescript action:

tell application "System Events" to tell process "Atticus"
	click menu bar item 1 of menu bar 2
end tell

You might need to try “item 2 of menu bar 2" or another permutation.

I think I see an error (or two) in your new macro. Your new macro's second mouse action now says "relative to the front windows upper left corner" instead of what it used to say in your first version of this macro.

Oh, sure. I was sloppy about this one - all I cared about was seeing it find the image, the step of the macro where it moves the mouse.

Seeing it seeing, if you will. :slight_smile:

I just deleted that step. I'm convinced that somehow this application is in some vram or memory space that we can't get to for some bizarre yet mundane and definitely irritating reason. :wink:

Any other thoughts? Like the applescript idea, any lateral thoughts?

The thing that is important with this is, this is the application that I'm gonna be using to edit and write my books. I've got three written inside of it, and I gotta go through an edit and using the mouse every damn time to do some of these operations is a massive pain.

thank you for looking, I really appreciate it

as I said to someone else and comment later down this is an application that I'm gonna be using to write and edit my books...

And that menu bar doesn't come with more than the standard Mac shortcuts for bold/italic/etc.

I would kill for markdown, but I'm not sure that will happen. They are more aiming at the creative writing crowd. Well, you can certainly argue that part of my writing is creative fiction. I try to minimize that as much as possible, even while making it interesting. :slight_smile:

Edited to add: thank you for the applescript I'm gonna give that a try. I got tooooo fixated on a keyboard maestro solution because it's just...easy. :slight_smile:

Ah, now I understand. A picture paints a thousand words, and all that. :wink:

Unfortunately that attempt at an Applescript solution won't help for such a menu, but I suppose you could open Atticus in the Script Editor app (⇧⌘-O) to see if it is scriptable. I wouldn't be too hopeful though.

If you just delete that step, then your macro won't work, because your macro no longer contains a click action.

I highly recommend that you upload copies of your macro instead of screen captures or descriptions.

Doubtful. But it may be that what you think of as "the front window" isn't the PWA's actual front window.

Go back to checking the full screen for now. Play with the "fuzziness" of the match -- your previously-working macro had a lot higher setting. You've also changed the image you are matching against, previously it was a saved file -- if you are now pasting an image in the action's image well then the best way to capture it is to ⌃⇧⌘4, drag round the area of interest, then select the image well and ⌘V to paste.

Apologies to all for the off-topic question, but I'm rather interested to know how you came by/chose to work with this software? I'm an inadverent collector of writing apps (in full spite of almost always vastly preferring to simply write in LaTex), and I've never heard of Atticus before, so I'm curious to learn what you like about it/what it does for you that others don't.