Application Moves Between Monitors When Resizing (Monterey)

I have a macro to resize my screen to a consistent size so other macros will work. Used this for several years.

Now with Monterey when I run the macro to move and resize the screen on my extended monitor the screen jumps back to the computer monitor.

This macro has worked well until I got a new MacBook Pro running Monterey.

When you say "move and resize the screen" do you mean "move and resize a window"? If so, which window? If not, I'm not sure what you mean. Are you willing to upload the macro?

Yes I mean realize a window.
Here is the Macro

That will help me run the test on my own Mac, using my iPad as a second monitor.

I run this macro to besure the size of the window is the same so my other macros which move and click will work

Okay, I tried your macro (on a Mac Mini.) I can confirm that it does move the window from the secondary (iPad) monitor to the Main (4K) monitor. I'll have to believe you that it behaved differently in earlier macOS versions. There is no mention of monitor behaviour on the KM wiki page for this action....

https://wiki.keyboardmaestro.com/action/Manipulate_a_Window

My first theory was that the coordinates for this action are based on the overall combined coordinates of all screens. But when I moved my secondary window to the left of my Main window, I was able to disprove that idea. I don't have very much experience with moving windows across displays using KM.

So now I'm leaning on the idea that this KM action has undergone an unexpected change, @peternlewis ? ... I bow in humility before KM's creator because I'm rarely right when I make a claim like this.

The coordinates are based on the top left corner fo the main screen, which is the screen with the menu bar in it in the System Preferences display arrangements.

The resizing is done with accessibility APIs, and they do not generally like the window to be resized off the screen, so ensure your size is smaller than the screen it is resizing on. The action has to be done by setting the position and the size independently, and if either results in the window going off the screen, then the system may ignore the change. So Keyboard Maestro applies both changes twice.

It is possible Monterey handles these things differently.

1 Like

If the original poster is correct about previous macOS behaviour, then I think it's correct to say that Monterey has changed something, because even when I'm trying to relocate a small window within the size constraints of a secondary monitor, it always moves it to the main monitor now.

Previously for a number of years this macro worked well on a macbook of 2012 era running catalina (that's the highest OS that machine would run)

I got the new machine. MacBook pro 16 with mx1 max running Montery. That is when this behavior started.

I don't know how to make the screen be the same size as I did with the macro.
I have a lot of "move and clck" macro entries that are predicated on the screen being a certain size and position.

Your wisdom is appreciated.

If your macros are running on multiple monitors and Monterey has changed it's behaviour resulting in KM changing its behaviour, then I think you may be forced to rewrite some of your affected macros. There're more than one way to change your approach: (since none of these methods involve repositioning the window, they won't move your window to a different screen)

  • use KM's menu click action in apps rather than click with the mouse
  • Use relative points within the front window to click the mouse
  • use relative points, relative to an image on the front window
  • use AppleScript to press buttons in apps rather than click with the mouse

We can help you with any of these approaches.

Ta Da...... I discovered this morning that if I have the move to horizontal coordinate be a negative number it will position it correctly on the extended display.
I just had to play around to get the correct number. I think I got its

Thanks to Sleepy and Peter for their help. I hope this information will help others.

Bob

Additionally...... if an app opens on the laptop and I want the screen on the extended display. this macro with the negative number will move it from the Laptop onto the extended display

I never thought of trying negative numbers. I thought the base (0,0) would move. Good job.