Macro for top application on different monitor

Like many people I dislike switching from keyboard to mouse and vice versa -- it slows me down.
To that end, I've created macros that click in the middle one of my monitors. More often that's enough to select the window I want and bring it into focus. But that changes the active widget in that window and usually, I want to continue what I was doing on the widget that was in focus. Is there a macro that would bring into focus the topmost window on a particular monitor? Furthermore, my monitor configuration isn't consistent as I work from home. Is there a way to detect the monitor/hardware setup and enable/disable certain macros?

Perhaps something like this already exists? Still learning this tool.

Take a look at the posts in this search. Should be something in there to at least get you started.