Move and resize window in another screen

Hi there,

I was wanting to create a macro that will move a window from my external monitor to my Macbook Pro screen. The ‘move and resize front window’ in ‘manipulate a window’ is the correct action but the ‘SCREEN(Main,Left)’ command ensures that the window expands on my external monitor, not my MBP screen.

I tried changing ‘SCREEN’ to ‘MONITOR’ but the text went red, which is never a good thing. Is there a way to open a window in my external monitor and have it move to my MBP screen and go full size?

Any help or advice would be gratefully appreciated.

Cheers

Aaron

Use SCREEN(External,Left) or SCREEN(Internal,Left)

One issue you can sometimes hit is if the move or resize will move or resize the window off an edge of the screen, then the accessibility system can refuse (and since the action needs to be done as a move and a resize, either can fail). Keyboard Maestro tries to ensure the action will happen regardless of the settings (assuming it is possible).

But if you hit really intractable cases, you can try resizing the window to be relatively small, then moving it, and then resizing it to full size. Generally this should not be necessary, but it is possible.

3 Likes

Changing it to SCREEN(Internal,Left) worked perfectly!

Thanks Peter :smile:

I have three displays and I would like it to resize on the display it is on. Main monitor is in the center, Monitor 1 left, Monitor 2 (main monitor center), Monitor 3 right. "Main", "Second", "Third" and "Internal" do the same thing, "External" sends it to the first monitor.

"Added Main , Second , Third , Internal , External as special screen indexes for SCREEN() ."

This is terrific. But is there any way of doing this more generally? Say I want to move a window to the next screen to the right, looping back to the first screen at the end? Something like

SCREEN((Current+1) mod ScreenCount, ...)

Assuming you have 3 screens, you can use:

SCREEN(Back2,…)

If you have two screens, you can use:

SCREEN(Back,…)

If you have more than three screens, or you don't know how many screens you have, then you have to use conditionals along the lines of:

If WINDOW(1,Left) < SCREEN(1,Right) AND (SCREENCOUNT() >= 2)
    Move to screen 2
Else if WINDOW(1,Left) < SCREEN(2,Right) AND (SCREENCOUNT() >= 3)
    Move to screen 3
Else if WINDOW(1,Left) < SCREEN(3,Right) AND (SCREENCOUNT() >= 4)
    Move to screen 4
Else 
    Move to screen 1
1 Like

Thanks, this just helped me fix a problem I was having!