Is It Possible to Determine Which Window Is in Which Monitor?

I'm trying to write a macro which will allow me to toggle focus between my primary and secondary monitor's top window.

However, I seem to have reached a impasse due to not being able to determine the windows location.

Is there a way to solve this problem?

Assuming you are talking about the currently focused window, then you can use this action:

image

SCREEN(Back,MidX)-WINDOW(Width)/2
SCREEN(Back,Top)+20+(SCREEN(Back,Height)-95-WINDOW(Height))/3

The SCREEN function can reference the Front or Back screens, the Front screen being the screen he front window is on, and the Back screen being the left-most screen that is not the Front screen.

Similarly, the WINDOW function can reference the the window coordinates of the selected window.