If KM pallette open, is that the "front window"?

I'm running a macro from a floating KM pallette, and want it to click in the front window (at a matched image). However, it seems to consider the KM pallette to be the top window, which doesn't seem useful.

If KM has a floating pallette open, and a "click" action specifies "in the front window", does the "click" action only click in that pallette? If so, then I'll suggest that KM should ignore any KM pallette when deciding which window is the "front" one.

A palette would never be the front window unless it has keyboard focus (which Keyboard Maestro palettes do not have).

Perhaps it's because I'm triggering that macro by clicking on that palette?

It should not make any difference. I suggest you create a duplicate of your macro, simplify it down to just demonstrate the specific problem, and then post that here. It may be that in the process you discover what the problem really is, or maybe you can produce a simple macro with the problem demonstrated and then either I can resolve it or explain why the behaviour is not what you expect.