Move Window to the Other Monitor?

I have two external monitors. I need a macro to move the current window to the other monitor. If the window is maximized, it should stay maximized on the other monitor. Is this possible?

I have not found any specific Action to move a window to another monitor.

1 Like

I've tried Spectacle, but it does not exactly do what I want (e.g. keeping the Maximized status, and other things).

Try this on for size...

You could also try the Rectangle app as it has the ability to resize the window after moving to match it's size on the previous monitor.


03)Reposition- next screen.kmmacros (3.1 KB)

I'm using different method with Citrix application as an example. Might be also usable for your case?
As I have created a macro to log me in automatically to my work environment, I wanted to be sure the Macro works always independent if I have second, third or only the main screen with me.
I'm not sure how to check, if it's already maximised and where it was suppose to be though.

I have found out that Spectacle does work if I do the following sequence:

  1. Manually un-maximize the window (by double-clicking the window's title bar)

  2. Execute the configured Spectacle shortcut to move the window to the next monitor(Shift+Command+RightArrow)

  3. Manually maximize the moved window (by double-clicking the window's title bar)

However, I've found no KM action for doing any of these 3 steps.

Ok that's a little different than what I understood from your initial post. You had mentioned maximizing a window, which to me is different than making it full screen.

I'm not sure of how to toggle full screen from Keyboard Maestro as I never use full screen.

But for the second step you could the simulate a keystroke action, sending it directly to Spectacle. Some apps respond to this action well and some don't.

You are right: A MAXIMIZED window is not a FULLSCREEN window. When a window is MAXIMIZED, then the KM Actions to manipulate the window size do not work.
How else could maximizing/un-maximizing a window be done?

I believe you have that backwards... when an app is full screen, KM cannot manipulate the window... but when it is maximized then the manipulate a window actions work just fine.

Either way, I do not know of a way to reliably toggle full screen from KM since each each app has that option in a different menu.

I'm sure others will chime in here who have experience with full screen macros.

Thanks for your help. When you double-click the title bar of a Mac app window, does it become maximized or full-screen?

Glad to help in any way I can. Double clicking the title bar will maximize a window (called zoom in the preferences pane). It does not actually make it full screen. Typically to do that you have to click the green circle icon, select the corresponding menu item, or use the hotkey that some applications have assigned by default, or assign your own hotkey either in the system preferences (keyboard pane, Shortcuts tab), or through a third party app such as KeyCue or Keyboard Maestro.

Thank you very much. So now I have learned that "Zoom" TOGGLES between maximized and un-maximized state of a Mac app window. Unfortunately, doing the Zoom action always toggles between the two states. But what I need is an "Un-Zoom" action that does not maximize the window when it is un-maximized. I.e., I would need to detect if the window is maximized and "Zoom" it only in the case it is maximized.

Here's something I whipped up real quick that should tell you if the front window is maximized or not.

In my very limited testing it works well, even on external monitors. However, I cannot guarantee it will work perfectly as I made it while in the middle of a phone call :sweat_smile:

The logic is pretty basic, it gets the front window size and position, sets them to coordinates, then gets the front screen size and sets those to coordinates, subtracts the size of the menu bar and then compares the two sets of variables to see if the window size matches the screen size. It will then tell you if it is maximized or not.

The variables are deleted at the end of the macro (these can be converted to local variables if you wish).

Try it out and see if it works for your needs.


EDIT (Wednesday, December 22, 2021 @ 15:27:38 PM):
I updated this to make use of some tokens @ccstone pointed out to me. In my limited testing it works quite well on a variety of screen resolution and configurations.
@Peter_Panino while perhaps it's not necessary anymore, this updated macro will tell you if your front window is maximized or not.

Get useable area of front screen.kmmacros (7.6 KB)


As you can see (doing this with a maximized window), the width is not the same because I have my dock on the LEFT screen side. (Of course, this applies only to the main external screen).

Taking all these factors into consideration, it would become too complicated when doing the calculation with KM Actions. Probably it would be easier doing this with a standard programming language.

I very much appreciate your effort and your generosity!

Ah man I didn’t even think about the dock! I tested this with the menu bar hidden and exposed and it worked fine, but I keep my dock hidden all the time and didn’t think about factoring that in.

While you're probably right that this is probably something best left to another method, it does make me wonder if there's a function that indicates the dock dimensions... back to the drawing board :sweat_smile:

I hope there's a way using AppleScript. but if not, I could imagine a complicated KM app that could find the dimensions of the dock. I've done something nearly identical before (finding docks inside macOS apps) but it took me weeks of work to implement it.

It actually looks to be quite easy to get all the dimensions of the dock using System Events. For my purposes the only thing I was interested in was the vertical position, which the below macro appears to get reliably, even when it is hidden.

To get all the dimension related info this is what I used:

tell application "System Events"
	tell application process "Dock"
		set listA to every attribute of list 1 --gets value of all attributes
		set AXPosition to value of attribute "AXPosition" of list 1 --gets position
		set AXSize to value of attribute "AXSize" of list 1 --gets size
		set AXFrame to value of attribute "AXFrame" of list 1 --gets frame
	end tell
end tell

@peternlewis is there a native Keyboard Maestro way to get the size/position of the dock like we can do for the menu bar using the MENUBARHEIGHT() function?

Get dock position.kmmacros (2.8 KB)

Don't forget that the dock can occur on the left, bottom or right side of the screen.

Yea I know, but for my purposes I was interested in vertical position since my dock is at the bottom. It would be quite simple for end-users to adjust this macro in case their dock is in a different location. I just haven't had time to expand on it yet haha :grin:

EDIT: A pretty simple modification to get both horizontal and vertical positions. Works whether the dock is on the left, right or at the bottom, whether it is hidden or not.

Get dock position.kmmacros (2.9 KB)

@Sleepy and @Peter_Panino I don't know if this would be useful to either of you guys but I wrote this macro to get the Dock information (like size, orientation and if it's visible or hidden) and display actual useable screen space according to that info.

This could likely be used in conjunction with the macro I posted earlier to determine if a window is maximized or not taking into consideration the Dock and not just the menu bar. I'll work on that as the day goes on.

EDIT: On another note, does anybody know how to collapse the macro image preview?

EDIT 2: Just realized this doesn’t take into account the menu bar height... I need to adjust some calculations and will update it shortly.

EDIT 3: I hate screen functions... running into issues reliably setting variables for multiple screen configurations. Pretty brain dead now so I'm gonna quit for the evening and take another look at this tomorrow.

EDIT 4: Because of difficulties in determining whether or not the menu bar is hidden, this macro does not work 100% when using more than one monitor. I'll leave it up for now, but I might not be able to figure out a way to get it to work reliably on multiple monitors or it might take me some time.

Get dock position (detailed).kmmacros (12 KB)