KM maps the screen coordinates as a continuous range across all of your monitors.
For example, the left edge of Screen 2 is one pixel more than the right edge of Screen 1.
So, to move a window to another monitor, you have to set it's coordinates to those within the desired monitor.
Maybe it will be more clear if I just show you. Here is my macro that moves the frontmost window from the current monitor (screen) to the other monitor.
Please feel free to ask any questions.
##Macro Library Move Window to Other Monitor (Screen)
####DOWNLOAD:
<a class="attachment" href="/uploads/default/original/2X/a/aa4fe5267e6d9ba3083f4c80e5accdaceb75bc09.kmmacros">Move Window to Other Monitor (Screen).kmmacros</a> (18 KB)
NOTE: The macro was uploaded DISABLED, so you will need to enable it before you can trigger it.
---
<img src="/uploads/default/original/2X/a/ab307eb8387c6b59ff2c0772fb15a631b26c8ede.png" width="466" height="1418">
Thanks!
So conceptionally that makes sense to me, but a couple implementation questions.
how do know the coordinates for my screen(s)
My display arrangement is not the typical 1 screen next to the other. I have 1 34" ultrawide in Portrait mode on the left, and 2 different sized and resolutions screens next to it one atop the other.
Instead of just gabbing the active window can I have it grab a specific window no matter where it is or if it is active or not? So for example when on a skpe call sometimes the little window with the picture of the other person gets hidden or moved. Can I have a keypress find it, activate it and move it to where I like it?
It's not really Keyboard Maestro that maps the screen coordinates this way, it is how the system behaves, though these days the behaviour is more confused because each monitor is now treated as its own space by default.
The origin (zero point) of the desktop is the top left corner of the main screen, which is the one with the menu bar on it in the Arrange system preferences.
If it is a real window with a known title in the front application, then you can reference it directly in Keyboard Maestro.
@dtraub, maybe this diagnostic macro will help you deal with your screens (monitors):
Please post the results for you system/screens. I can't wait to see the coordinates of your screens.
I have used this to perfection on my 2 display set up but I am having a bit of a blank on how to get it working properly on my 3 display desktop setup.
My set up is 3 identical monitors which I have ordered
1 (Left), 2 (Middle), 3(Right)
I have adjusted the macro to move to the right display and left display (2 separate macros) but lets say a window is in the right most screen (3) and I hit the Move to left screen macro.
It moves the window to the left most screen (I know its because the True / False) Calculation so its working how ti should)
How can I get it to just go to the middle monitor (2) if its at the right most (3) and not skip to (1).
In fact, "-1" might be a really good choice, since it should always point to the screen to the immediately LEFT of the current FrontMost screen. But I have NOT tested this.
Instead of using the method I used above to ID the FrontMost Screen, here's a better method.
This macro calculates the Index of the current FrontMost Screen, which you can then use to get the coordinates of the screen on the Left (-1) or on the Right (+1).
So, if Local__ScreenFrontIndex is 3, and you want the Window moved to the screen to the immediate left of it:
IF (Local__ScreenFrontIndex > 1)
THEN Local__ScreenLeftIndex = Local__ScreenFrontIndex - 1
ELSE Local__ScreenLeftIndex = SCREENCOUNT()
END IF
Move Window to
SCREENVISIBLE(Local__ScreenLeftIndex,Left) + 50,
SCREENVISIBLE(Local__ScreenLeftIndex,Top) + 50
Below is just an example written in response to your request. You will need to use as an example and/or change to meet your workflow automation needs.
IF (Local__ScreenFrontIndex > 1)
THEN Local__ScreenLeftIndex = Local__ScreenFrontIndex - 1
ELSE Local__ScreenLeftIndex = SCREENCOUNT()
END IF
Move Window to
SCREENVISIBLE(Local__ScreenLeftIndex,Left) + 50,
SCREENVISIBLE(Local__ScreenLeftIndex,Top) + 50
The main problem was that you had pasted multiple lines into the Left Coord. field of the Move Action.
After you do this, there is no indication of it containing multiple lines -- this is a bug IMO.
So, I fixed your Move Action formulas, and moved that whole IF block out of the "ID Screen Group.
I also provide a new method, which I think is more efficient, to determine the Index of the FrontMost screen.
And I gave you a couple of goodies I always use when moving windows to other screens.
You can disable/delete them if you don't like them.
Below is just an example written in response to your request. You will need to use as an example and/or change to meet your workflow automation needs.
This is incorrect. -1 is the right-most screen. Negative numbers index the screens from right to left.
Back2 wont work to cycle through screens either, since Back2 will be the Screen 3, except when the Front screen is Screen 3, then it will be Screen 2.
Yes, this is a long standing issue with macOS and single-line fields, that it shows one line with no indication of any extra text. And yes, I should figure out a way of detecting it and showing, or just removing line breaks from such fields (and generally Keyboard Maestro does do this, just not in every single case unfortunately).
The way the KM Wiki is worded, it is not clear what the positive and negative numbers mean when referring to a screen. I read, and reread it several times, and could never get a clear understanding.
I am open to suggested edits for it. Screens are indexed from left to right with positive numbers 1, 2, 3, and from right to left with negative numbers -1, -2, -3, so with three screens, 1 ⬄ -3, 2 ⬄ -2, 3 ⬄ -1.
The same technique is used in a few other places, line indexing windows for example.
The cycle works great moving left! I looked at it yesterday to create a duplicate one that just moves the screens right but I couldn't figure it out.
From the other comments it looks like it should just be a number change in some of the actions but I still can't figure out which one it is! Mind giving me a hint!
By the way this community is amazing how helpful everyone is with these macros!
Hey sorry to be a pest but could you give me a point in the right direction for what I need to update to make this work going the other direction as well (Left to right)