Manipulate KM’s Display Text Window

Why don’t you just try it? You have the script in the first post.

To answer your question: yes, it seems to work also for palettes. This for example repositions my Global KM palette:

tell application "System Events"
  tell application process "Keyboard Maestro Engine"
    tell window "Keyboard Maestro"
      set position to {20, 45}
    end tell
  end tell
end tell

Replace the window name with the name of the palette you are targeting.

LIke @Tom says, just try it.
@ccstone has a script published in this forum that provides detailed window info.

Here's a simple version:

tell application "System Events"
  tell application process "Keyboard Maestro Engine"
    set winList to windows
    set winNameList to name of every window
    set AppleScript's text item delimiters to linefeed
    winNameList as text
  end tell
end tell

When I had a palette with the name of " [WIN Palette]" open:


[WIN Palette]
Keyboard Maestro

Thank you very much for good advice! I’m an AppleScript/KM novice, but based on your input I managed to put the below script together. It seems to work fine for moving single palettes that are not transient (it does unfortunately not work for palettes “for one action” or conflict palettes because they disappear when activating this script), although I have made only very limited testing. Note that it moves the palette to the center of the screen, which is what I prefer, but this is easy to change. The script is not generalized to be able to handle multiple palettes being open simultaneously. If you do not have SwitchResX you can comment out that part and try to use the SPDisplaysDataType shell function instead; however, this did not work well for me because it reported the maximal screen resolution instead of the current resolution. The bounds function may also be an alternative.

tell application "SwitchResX Daemon"
	set {screenWidth, screenHeight} to get {width, height} of (current mode of main display)
end tell
tell application "System Events"
	-- set screenWidth to (do shell script "system_profiler SPDisplaysDataType | awk '/Resolution/{print $2}'")
	-- set screenHeight to (do shell script "system_profiler SPDisplaysDataType | awk '/Resolution/{print $4}'")
	tell application process "Keyboard Maestro Engine"
		set paletteWin to first window
		set sizePal to the size of paletteWin
		set widthPal to item 1 of sizePal
		set heightPal to item 2 of sizePal
		set winList to windows
		set winNameList to name of every window
		set AppleScript's text item delimiters to linefeed
		set palWinName to item 1 of winNameList as text
		set adjXpos to widthPal / 2
		set adjYpos to heightPal / 2
		tell window palWinName
			set position to {(screenWidth / 2) - adjXpos, (screenHeight / 2) - adjYpos}
		end tell
	end tell
end tell

@Tom, I had to remove your plugin because the KM Editor.log was reporting an error:

2017-09-25 20:04:50 Invalid File for Plug In Action Manipulate a Display Text Window

Sorry, but I didn't try to diagnose or reinstall, since:

  • I have your equivalent macro
  • The only macro I was using it was a macro by @ccstone:
    Search Designated Text File and Display Results

In case anyone else needs to uninstall a plugin:

How to Uninstall a Plug In

  1. In the Finder, go to this folder (use ⇧⌘G )
    ~/Library/Application Support/Keyboard Maestro/Keyboard Maestro Actions
  2. Select the Folder for the Plug In, and move to Mac Trash

To be safe, I stopped both the KM Editor and the KM Engine before the uninstall.

Thanks for the note. I will update it ASAP.

I'm unable to reproduce that error. It works fine here with KM 8.0.1 on macOS 10.13.

I don't know what "Invalid File" exactly means. Maybe try to reinstall the plugin?

After reinstalling action plugins — if the action already is inserted in a macro — you should reload KM and KM engine:

tell application "Keyboard Maestro" to reload
tell application "Keyboard Maestro Engine" to reload

or simply relaunch them.


The issue has been resolved; see posts below.

Update for KM7 (26 Sep 2017, 21:20 Z)

Manipulate a Display Text Window (KM7).zip (7.7 KB)


Update for KM8 (26 Sep 2017, 21:22 Z)

Manipulate a Display Text Window (KM8).zip (7.5 KB)

I have removed the "Focus OK button" checkbox, since this has become the default with KM8. So, download this version only if you are using KM8+.


It means it is complaining about the Icon or Script key data.

Either it cannot read it, or the contents of the key does not look like a file name (regex match ^[A-Za-z0-9_]+(?:[.][A-Za-z0-9_]+)?$.

Note that this error happens before it looks at the file system, so it has nothing to do with whether the file exists or not, only the value of the key in the plist.

It's this:

	<string>Manipulate a Display Text Window</string>

Its simply complaining about the Icon. It’s not a significant error, probably it should not even be reported.

Well, on my machine it isn't complaining at all.

The only log entry after running a macro with that action is:

2017-09-26 12:32:30 Execute macro “[plugin test] Manipulate a Display Text Window” from trigger Editor

The Icon should be optional, so I’ve stopped it reporting an issue if there is no Icon key, but it would still complain about the Icon in that example.

What exactly do you mean with "complain"?

Running the action I don't get any notification nor any error in the log.

It should appear in the Editor log file and the Console log when you do something that would require the icon, which would mostly only happen if you display the action in the editor unless the action was the only action in a macro, then the macro might take on the icon from the action.

Ah, sorry I was looking in the Engine log all the time. Stupid me.

The message is in the Editor log, indeed.

So, what is the correct string for the default icon?

Edit / PS:

Or just leaving it as it is (=empty) and ignoring the message in the Editor log?

I found the answer myself:

I created an empty file “none.png” and use that as target:



It is not even necessary to create an empty file, just any non-empty string seems to suppress the message.

I’m a little on the slow side today :wink:

Just don’t include the Icon key or the string at all.

That is how it should be. You’ll get the message until the next version.

But yes, if it references a non-existent file, that will work, but down the track, that might complain.

1 Like

Yes, indeed, this is the clean solution. Thanks for the hint. As said, really on the slow side today :sleeping:

Thanks for the quick response and update Tom, and for the KM8 version.
I will download and install.

Well, since my plugin apparently has found its first user — and, on top of that, one who is reporting issues — it goes without saying that I will do my best to care for that user :wink:

Thanks, BTW, for your update note in the original plugin post.

In the actual update post I have replaced your yellow "Update" image by actual text, because I don't think it is a good idea to replace text with images, even if it's only one word.

But, to maintain the emphasis, I added a nice icon. It's from the free version of Font Awesome, downloadable as image data from here.

Link to the post with the icons

That's fine. It is your post and should reflect your style and preferences. :wink:

I still like the "updated" image because it is a replacement for rich text that is not available in the forum. IMO, the yellow is a better eye-catcher. :smile:

For decades now, we have seen the word "new" as a graphic image to call attention to something, better than just a text word would do.

I'm not a big fan of the bell icon, but I'll have to take a look at all of the icons to see if there are any of interest. Thanks for sharing.