Moving the Applications Palette based on Displays

I have up to three displays and I use them in specific manners, but I don't always have three. Sometimes I only have two, or just one. They have different resolutions, and I generally don't change resolutions.

Desire: How can I get the Applications Palette to move to the upper-left of the right-most display?

Displays are indexed 1, 2, 3... left-to-right -- but you can also use -1, -2, -3... to go right-to-left. So %ScreenVisible%-1% will always get you the bounds of the rightmost screen, however many are connected.

The Applications Palette is a Keyboard Maestro engine, but hiding/showing it doesn't gives us a "Last Engine Window ID" we can use :frowning: But we can get it with AppleScript -- it's the Engine window named "Applications" -- then use the ID in a "Move Window" action.

Here's a demo:

Move App Palette.kmmacros (2.9 KB)


I only have one screen, so it's all rather theoretical -- but it does work on a single screen!

Note that if you ever pop up a "Custom HTML Prompt" window or similar titled "Applications" there's a chance of confusion, although the App Palette should always be the first item in the list. It's a pretty slim chance so I haven't included any error checking, but bear it in mind if the macro misbehaves...

1 Like

Thank you. That helps.

Observation: I have noticed sometimes when I restart with 3 displays, the numbering of displays does not work consistently. To explain, let's say I have an external ViewSonic Display and an external Dell Display connected to my MacBook Pro. I see the following two situations even though I do not change the settings:

# Restart 1 Restart 2
0 MacBook MacBook
1 MacBook MacBook
2 Dell ViewSonic
3 ViewSonic Dell

Fortunately, I do not reboot often and I can use a persistent variable to address this issue, which I can manually update at startup time.

I just realized by rotating the table I can see some other information. In the
following map:

Display Name Width Height
MacBook Pro MacBook W0 = 2560 H0 = 1600
View Sonic VendorA WA = 1920 HA = 1080
Dell VendorB WB = 3360 HB = 1890

The arrangement is left to right with the tops of all displays aligned (so that menu bar alighns).

|   0   |  A  |     B     |
|       +-----+           |
|       |     |           |
+-------+     |           |
              |           |
Arrangement L2R MacBook Calc Vendor1 Calc Vendor2 Calc
Restart 1 order 0/1 2/-2 3/-1
Restart 1 Left 0 0 W0 2560 W0+WA 4480
Restart 1 Right W0-1 2559 W0+WA-1 4479 W0+WA+WB-1 6939
Restart 1 Top 0 0 0 0 0 0
Restart 1 Bottom H0-1 1599 HA 1079 HB 1889
Restart 2 order 0/1 3/-1 2/-2
Restart 2 Left 0 0 W0 2560 W0+WB 5920
Restart 2 Right W0-1 2559 W0+WB-1 5919 W0+WB+WA-1 6939
Restart 2 Top 0 0 0 0 0 0
Restart 2 Bottom H0-1 1599 HB-1 1889 HA-1 1079

The middle column is the key. So I can compute the ordering as long as the widths are different and I know the width of the MacBook and one of the other two. If they're the same, it does not matter. For my situation this can be hardcoded since I always have the middle screen resolution set to 1920x1080 (used for streaming broadcasting).

KM's indexing is taken directly from the OS, and so should be the same as the display arrangement shown in Display Preferences/Settings. Are you not seeing that?

Macs generally remember screen layouts and automatically apply the last arrangement used for a set of connected screens when they are reconnected. It may be that you have two "saved" arrangements -- one for when it connects to the ViewSonic then the Dell, another for the Dell then the ViewSonic -- and you're falling victim to a connection timing issue.

There might also be a problem with sleep/wake, if it is a timing issue. So I'd look at doing a check every time the macro is run by:

  1. Getting %Screen%All% -- one screen frame per line, left-to-right
  2. Counting down the list to get the number of the line whose width value is 3360 -- call it n
  3. Using that number as the index in the first action above -- %ScreenVisible%n%

That'll work as long as the Dell is connected. You said in your OP that "but I don't always have three" so you'll have to think about the logic of that with respect to the physical screen layout in those situations.