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:
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
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.
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.
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.
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
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.
That's fine. It is your post and should reflect your style and preferences.
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.
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.