Move Finder windows off a specific display

Hi, I have 3 displays, and use my iPad as a 4th display on occasion via Sidecar - for reasons that are strange and inexplicable, it makes older OpenGL software work correctly when it's enabled.

However I don't actually have the iPad display visible - it stays locked on a table, with the cover closed and screen off, though the system still thinks it's a display.

Unfortunately Finder insists on occasionally spawning windows to it in that state. So, is it possible to make an KM action with the logic of:

If: Finder Window on (display 4)
Wait a second.
Move to: (Display 1)

Thanks.

Assuming you mean the main display (SCREEN(1) is your top-left screen, which may or may not be your main screen) and that this is a new window and hence grabs focus -- try this in a Macro Group that is only available in the Finder:

New Screen 4 Window to Main.kmmacros (4.1 KB)

The calculation puts the top-left corner of the window at the same x,y from the top-left of the main screen as it was on the iPad screen -- change those values to hard-coded numbers (eg 100 and 200 if you want it always moved to the same place. Also do that if the window is always full-screen on the iPad (I don't use Sidecar, so can't test).

If these newly-spawned windows don't have focus for some reason you'll have to look for another way of triggering the macro.

1 Like

Sorry, I missed the notification for this...

No I don't have top left really as a reference point.

But, if the Screen Index test will effectively activate when I switch to Finder, and it either opens a window on the iPad, or there is already a window on the iPad, the names of the displays are all available to Finder under the window menu, so the move action could no doubt just be done with a menu selection macro.

Is the screen name as shown in Finder's Window menu a testable condition?

Sorry, I wasn't very clear.

The coordinates 0,0 are the top-left corner of your main display. The macro above moves a window to the same relative position on the main display as it was on screen 4, plus moving it down a bit to account for the menu bar.

So if you had two "normal" displays and the window was 100 pixels in and 100 pixels down on the secondary it would be moved to 100 pixels in and 100 pixels below the menu bar on the main.

If you always want it moved to a certain position you can hard-code the numbers rather than calculating them:

image

You still have to screen index test, since "Move to Built-in Retina Display" will be available for any frontmost Finder window not on your main display (that's for multiple "normal" displays, Sidecar may behave differently).

So if the window is on the iPad the "Move to..." will be available -- no need to test. So this might work (you may need to change the menu item to suit your system):

New Screen 4 Window to Main by Menu.kmmacros (3.7 KB)

What you do lose is the ability to position/resize the window at the same time -- though that may not matter.

That's not actually available on my system, as I have no built-in displays, but the main display does have an identifier that remains consistent in the menu.

My hesitancy of the Screen index test is that it presumes the iPad will always be screen 4 - my system can drive 6 displays on its graphics cards alone, and I'm willing to bet the iPad gets added as the highest number.

Is there any way to use a display name test, rather than a numerical ID?

Screens are numbered from top-left (1) to bottom-right (n), as shown in System Settings -> Displays -> Arrange... Play with different arrangements in that, along with "Display Text" KM action using the %Screen%All% token (which returns a list in screen index order) to see how it works.

If the iPad is always added as the "last" screen then you can access it using the index -1, just as with other KM lists (negative indices count from last to first items in a list).

There's no such thing in KM. You might be able to glean that information from the available menu items in Finder but, obviously, those will be particular to your setup -- you'll have to try things out for yourself. Look for what menu items are or aren't available when a window is or isn't on the iPad, eg

...would be true when the front window was on the iPad.