Clipboard History Switcher Window: Remember Placement or Move via Macro/Script

I want to start using the Clipboard History Switcher. I have 3 displays, my iMac 27", and 2 other displays; one to the left, one to the right. I'd love to see the CHS window show up on screen 3 @ top, left, width 30%.

I've run into a couple of problems:

  1. If I place the CHS window on any other display. The next time I call it with a macro using Control Spacebar, the window shows up on my iMac in the same relative screen location I placed it on either of my 2 other displays, not on the display & position I originally dragged it to.

  2. If I add a move window command to that macro, and use "in Front Application" both the front application window and the CHS window get moved.

  3. If I try to use the window named Clipboard History Switcher I get this error:

This one has me scratchin' my head.


The KM windows are different from most, and are not readily detectable by normal means. Take a look at this macro by @Tom:

Macro: Manipulate KM"s Display Text Window

You will need to change this line in the script:
tell window "Keyboard Maestro - Display Text"

to be the name of the Clipboard Switcher.
My first guess would be: "Clipboard History Switcher" :wink:

Good luck and let us know how it goes.

@AsburyParkJoe, confirmed the name.

You can see it by running this script in the Script Editor, with the Clipboard History Switcher open.

tell application "System Events"
  tell application process "Keyboard Maestro Engine"
    set winList to name of every window
  end tell
end tell

--> {"Keyboard Maestro", "Clipboard History Switcher"}


What I've learned via this "exercise":

  1. The behavior of the Clipboard History Switcher window is beyond odd.
  2. I was not able to manipulate it in any form with AppleScript; though I tried every conceivable thing I could imagine. I could not open, close, resize, get the visible of, — nothing. Even trying variation of the script you linked to.
  3. After trying the KM macro below, I could not get the Clipboard History Switcher window to resize to the height of Screen 3. If the KM window resides on Screen 1, and the macro is executed, the Clipboard History Switcher window opens on Screen 1, then moves it to Screen 3 and resizes — but NOT to the screen height of Screen 3. It retains the height of Screen 1.
  4. If I move KM window to Screen 3 and execute the same macro, the Clipboard History Switcher resizes to the full height of Screen 3.


I did resolve the issue of dealing with the KM Engine by opening the KM package & selecting the actual And by just using "The Front Window" rather than naming the window Clipboard History Switcher. When I did the later, I'd get an error if the Clipboard History Switcher was already open, and the macro was trying to close the window rather than open it.

The way I resolved the Clipboard History Switcher window NOT resizing to 100% on Screen 3 was to just move the KM window to Screen 3 and use it to edit with on Screen 3. The things we do! But it still makes no sense to me WHY the Clipboard History Switcher would not resize to 100% on screen 3 if the KM window was on the smaller Screen 1. Another head scratcher.

Thanks for you help! :+1: :slightly_smiling_face: :+1:

You're welcome, although I'm not sure how much help I really gave you. :smile:

When I get a few minutes, I'll do some more testing with AppleScript and see what I can obtain. It may be a day or two, but it looks like you have a workaround for now.

The Accessibility API will not generally let you resize a window off the edge of the screen. So you can't resize it to larger than the screen size it is on.

Keyboard Maestro generally does this sort of thing by moving and resizing and moving and resizing. Normally the latter two do nothing, but in some cases they are required when the accessibility API refuses.

It looks like

tell app "Keyboard Maestro Engine" to windows

returns nothing at all. Curious.

The system normally handles that itself, so I don't know why it decided not to.

This script works fine for me, to move and resize the ClipBoard History Switcher.
I'm running Keyboard Maestro 8.0.2 (8.0.2) on macOS 10.11.6


tell application "System Events"
  tell application process "Keyboard Maestro Engine"
    set winName to "Clipboard History Switcher"
      set oWin to first window whose name is winName
      tell oWin
        set propList to properties
        set posOld to position
        set position to {100, 20}
        set sizeOld to size
        set size to {1000, 1100}
      end tell
    on error errMsg number errNum
      display dialog "Window NOT Found: " & winName
    end try -- try
  end tell
end tell

OK, I looked in to this. the AppleScript “windows” property, like Keyboard Maestro itself, normally only deals with normal windows, so none of Keyboard Maestro Engine’s windows ever show up. As noted, you can get to them from System Events via “tell application process”, but it is not ideal.

Since Keyboard Maestro Engine has no normal windows, I have adjusted it’s windows property to return all windows and panels. So in the next version you can do things like this:

tell application "Keyboard Maestro Engine"
	properties of windows
	set bounds of window "Keyboard Maestro - Shell Script Results" to {200, 300, 600, 700}
	set bounds of window "Clipboard History Switcher" to {1000, 46, 2000, 1177}
end tell