Am I able to refer to a display by its ID instead of First, Main, Second in Move and Resize Front Window action?
I use an iPad with duet display as a fourth monitor, but I don't always have it connected. Using it changes the display hierarchy, messing up certain window macros. Is there a way that I can tell KBM to refer to a specific screen and have it perform actions on that screen no matter what displays are connected?
I'm not trying to argue with you, I'm just trying to understand what you want.
When you say "refer to a display by its ID," what is the ID of a display? In KM, the only ID that it uses is a sequence number starting from left and going to right (top to bottom if they share the same left value.) What is your definition of a display's ID? If I have two 4K monitors, what is the ID for each monitor? When I look at the details of my 4K monitor, I don't see any unique ID number. How is KM supposed to assign IDs to monitors that don't have IDs?
Also, it's not 100% clear whether your phrase "messing up certain window macros" refers to private macros that only you are using, or refers to macros available on this website, or refers to window-related actions available in KM. If you are talking about your own macros, there may be ways to fix that to account for the display changes you are triggering.
I'm just trying to help. My heart is in the right place. Basically, if you want KM to be able to address specific screens by name, there has to be a naming scheme, and I can't see what that scheme could be.
The display's number changes when the iPad is plugged in. Referring to the second display when the iPad is connected does not refer to the same display when the iPad is disconnected. So it messes up macros that perform actions like move a window to the right side of the second display. It would move the window to the display that Keyboard Maestro currently sees as the second display instead of the one that it saw as the second display when the iPad was plugged in.
I am trying to figure out if there's a more robust way of telling Keyboard Maestro to position windows. The "Main" command always refers to the main display no matter what, is there a way I can always refer to specific displays no matter how many monitors I connect or disconnect? Can I ensure that my macros will always work if the displays change?
I'm sure that there is a better way to make this macro, what it does is swap the position of the two most recently accessed apps on a certain display. Or depending on what I'm using it for it will put the two most recent apps into position on that display. I would like to be able to do this with two windows of the same app but I haven't figured out how to do that yet.
But even if I can figure out a better way to execute this macro, it would still be nice to know if I can be sure that the macro will always position the window on the display I intend.
Thanks again, sorry for the poor explanation above.
In my last post I pointed out that there was no unique ID for monitors. Since that's the case, how would you propose that KM specify monitors for you? How do you want KM to distinguish between two monitors if MacOS doesn't have distinguishing names for them? It seems that KM has resolved this problem by giving monitors a number starting from the left/top and going to the right/bottom. That seems reasonable. But if you don't like that method, then what do you propose? If there's no way to name monitors uniquely, how do you propose KM deal with that?
Moving apps across monitors is an extremely difficult process to define, since monitors come in different shapes and sizes. There is a thread about this topic somewhere on this website. I think there are also macros on this website that attempt to deal with that problem.
Nevertheless I have an idea. If your monitors all have unique sizes, then you can use their sizes as their name. That will give you the unique ID to tell which monitor is which.
The iPad is the only one that has an irregular size. The others are 2560x1440.
Forgive my ignorance, how does an app like Moom keep its snapshots then and have them work when additional displays are added?
I wouldn't know about Moom, but many utilities don't hesitate to use undocumented APIs in MacOS, whereas KM refuses to do that. Typically this makes other utilities more powerful than KM, but at the expense of breaking every time MacOS gets upgraded. KM 3.0 still runs on MacOS because it won't use undocumented APIs. Anyway, I don't really know why Moom can do it. But that might explain it.
When you add the iPad, how exactly does it mess up your screen order? KM orders screens from left to right. If you add an iPad in the middle, that will indeed mess up the order of the monitors. But your code can account for that because your iPad has a unique resolution. I can imagine how you could fix your code to work correctly by recognizing the iPad's existence by noticing its unique screen resolution. But if you don't want to update your code to account for that, I understand completely.
My iPad is positioned below my main display. How do you think I fix the issue?
That's where I place my iPad too. So I think I have a plan here.
What you could do, I think, is determine if your iPad exists by going through all the screen sizes and checking if any of the screens have the resolution of your iPad. I think you can do this with the WINDOWCOUNT() and WINDOW() functions.
If it exists, then you can take that into account. I presume it's the only "moveable"/"disappearable" monitor in your setup. If the iPad doesn't exist your monitors will exist in some fixed order like 1,2,3,4 but if your iPad is inserted it will exist in some order which I will call 1,2,5,3,4 where 5 is your iPad. (But KM will renumber them as 1,2,3,4,5.)
So does this set your sails in the right direction? You need the WINDOW() function to determine if you have an iPad, and you need the knowledge of your monitors to otherwise know the rest of your arrangement. Does this make sense? I'm trying my best to come up with a solution for you.
Yeah! This should work. It's late right now, and I'm getting sleepy, @Sleepy thanks for all of your help and I'll let you know how it goes tomorrow!
I'm so happy I could help. I'm not always on the right track, but maybe today I was. Thanks.