Snap Palette to Front Window Plugin Action


#1

Snap Palette to Front Window

UPDATED VERSION 2016/06/15 (see reply below)

Snap Palette to Front Window.v1.1.zip (20.9 KB)

This macro will “snap” a Macro Group Palette to an edge of the current Front Window. Like this:

or this:

or even this:


This is useful in and of itself; additionally, it really helps when you drag a window, and you wish you could easily move its palette(s) to where you dragged the window.

Simple to use:

  1. Copy the UUID of the Macro Group whose palette you want to control:

  1. Paste the UUID into the Action:

  2. Pick where you want it to snap:

It’s a snap!

NOTES:

  1. If you change the snap position and try the Action again, from the KM Editor, it might not work the first time you change the position. I think it’s a quirk of Keyboard Maestro - the selection hasn’t registered yet, or something like that. It won’t affect how you’ll normally use the macro.

  2. The Snap Positions might be a little confusing at first, but try them and see what they do. Basically, the positions that start with “top” will be positioned along the top of the window. The ones that start with “left” will be positioned along the left side of the window, etc.

  3. If the palette was hidden, it will un-hide.

  4. Obviously, the Macro Group has to to be able to be “Active” for the window in question.

INSTALLATION

  • Drag the .zip file onto the Keyboard Maestro icon in the OS X Dock.

  • (if updating a previous version of the action, first manually remove the previous copy from the custom actions folder)

    • ~/Library/Application Support/Keyboard Maestro/Keyboard Maestro Actions

Sticky Palettes! They move when you do!
KM Inspiration Gallery
Get the current position of a Keyboard Maestro palette
Feature Request: Custom Menus and Palettes in Status Bar
Sticky Palettes! They move when you do!
Evoking Conflict Palette via KM "Type a Keystroke" action
#2

Great work. With the window-focus triggers, this makes for a nice “docked” palette (albeit with a 1 second or so delay). Super handy! (Although I do get some unexpected results with apps that have floating windows - Chrome always wants to attach the palette to the “hangouts” window docked in the corner of my screen.


#3

Thanks!

And especially thanks for your example. I didn’t realize the “frame changed” trigger works for dragging a window also. That’s awesome!


#4

Update Version 1.1!

(download is available in the first post).

Added “inside” positions, like this, “inside right top”:

UPDATING A PREVIOUS VERSION

To update a previous version:

  1. Unzip the zip file.
  2. Copy/move the 3 files inside to (replace existing files):
    ~/Library/Application Support/Keyboard Maestro/Keyboard Maestro Actions
  3. Shut down and restart the engine and the editor.

#5

Dan,

I’ve found this plugin invaluable in both versions since the day you launched it. I’ve noticed, though, that my palettes snap to any child windows, dialogs, and popup menus that the application spawns. You can see it doing it KM itself in the below screenshot. Is there a way to keep the palette attached to just the main windows (or document windows, as in the case of MS Word)?


#6

Thanks!

I’ve noticed, though, that my palettes snap to any child windows, dialogs, and popup menus that the application spawns

Yes, I’ve had this issue also.

Is there a way to keep the palette attached to just the main windows

Yes, although how you do it depends a lot on the application. The best I’ve come up with so far, is to add one or more IF conditions to check the window title, or check for a specific button, or something like that. Most often, I check it for something telling me NOT to snap the palette, like this, which I use for Finder:

I suspect that @ccstone might be able to come up with something more generic, based on window classes or some such thing, but this is the best I’ve come up with. It works, but I usually end up finding more conditions I have to add, as I continue to use it. :slight_smile:


#7

Been rummaging around trying to find UUID of Macro Group to paste into Snap Palette.

Going in round in circles. Where do I find it?

Ignore - found it!

Thanks

Michael


#8

Hey Michael,

Go to the search field in the Keyboard Maestro Editor’s Help menu.

Type “uuid”.

More will be revealed.

-Chris


#9

Cheers Chris. Should start with Help really!


#10

Holy moly this was just what i was looking for! Excellent :smiley: thx for @iampariah for pointing me to this


#11

Hi @DanThomas, since KM 8 I always get a message that there is something wrong with the plugin. This message appears with every activated app. Also for those (here Safari) where the Snap Palette Plugin is not installed.

The error messages do not stop until I deactivate the plugin.

Here is a short video.


#12

Hi appleianer,

I get also an error if the palette is set to “Shows a palette for one action”.

It works fine for me if the palette is set to

  • “Shows/hides a palette when” or
  • “Shows a palette until”.

Example:

Works:

Error:


#13

Thank you for your quick answer @Tom. Even if I take your suggestion into account, the messages come. There must be something wrong with the applescript

It’s confusing that the plugin works (video), but that these messages are always displayed and then also in apps that I don’t use with this plugin. I also only targeted the used apps, but even there I get the error messages in all apps.

Here is a screenshot of my settings. Under KM 7 this worked perfectly.


#14

Can you post the the error from the log? The message is not entirely visible in the on-screen notifications.

You can easily find the log: KMEditor: Help > Open Logs Folder. It’s the Engine.log.

No need to post the whole log file content, just the complete log entry that is made when the error happens. (An entry starts with a time stamp like 2017-09-19 22:46:03)


#15

Hi @Tom, I have the desired log file here.

If you need anything else, please contact me.

Thank you for your help.


#16

Weird. That’s the same error I had with “Shows a palette for one action” setting, as described above.

My guess was that — due to that setting — the palette disappears just in the moment before the AppleScript runs (thus the “no valid index” error). But I think this does not explain the behavior you are reporting.

I have to think.

BTW, you can copy from the log file (select the text, then press ⌘C) and then paste it here (⌘V). No need to post images :wink:


#17

I’ve just seen in your screenshots that you are showing the palette settings of the group where the Snap Palette macros are in.

What I meant in the other post is the palette setting of the group where the target macros are in (e.g. your iA Writer group or whatever).

Please check the palette settings of the target groups (“Shows a palette for one action” versus “Shows/hides a palette when”/“Shows a palette until”).


#18

Please excuse the misunderstanding.

I have now changed everything as you described it first and it works.
You really are an angel of Keyboard Maestro :innocent:

Thank you very much for your help :+1::clap:


#19

Happy that I could help!

Nothing to excuse. It was me who failed to tell you explicitly what palette settings I was talking about.


#20

Have you found a way to prevent snapping to QuickLook? I would be delighted to know it!