If your screens' arrangement can't be guaranteed then you'll have to derive the current arrangement somehow and then work from there. One way would be to use resolutions -- I've a suspicion that %ScreenResolution%All% is buggy, but you can build your own list.
%ScreenResolution% evaluates to
nominal width, nominal height, pixel width, pixel height, frame rate
...which for my iPad is
1016,810,2032,1620,60
I've used the nominal resolutions (set in the macro's first Action), searching for those in the generated list. The number of lines up to and including the found text is the screen index of the iPad and if it isn't connected then the search errors and the variable Local_iPadIndex is empty.
Demo:
Sidecar Screen Index Demo.kmmacros (5.9 KB)
