Sticky Palettes! They move when you do!

Sticky Palettes! They move when you do!

I like to have my palettes "docked" next to their windows, and if I move the window, I want the palettes to follow it. If this sounds good to you, follow the following simple steps.

First, download and install my "Snap Palette to Front Window Plugin Action".


Now, let's say we have a Macro Group called "Mail Palette", setup something like this:

We need a Macro Group that is available only when Mail is active, something like this:

And lastly (but see NOTE below), let's add this macro in the "Mail Active" Macro Group:

For "Macro G...up UUID" (aka "Macro Group UUID"): in the KM Editor select the Macro Group "Mail Palette" and then do "Edit->Copy as->Copy as UUID", and paste it here.


That's all we need with one caveat:


NOTE:

At the time of this writing, there's a minor glitch in Keyboard Maestro where the "focussed window" triggers we used in "Mail Palette" won't fire when the application (Mail in this case) is initially launched. You have to switch away from the application (i.e. Mail) then switch back to it one time before the palette becomes "sticky". Theres a workaround for this, below.


What if we want the Palette to stick to the application's "Main" window only?

If your application opens up other windows besides the main window, you may decide you don't want the palettes to snap to the other windows.

If you can find something unique about either the Main window, or the other windows, you can surround the "Snap Palette" with an "If" action, similar to this:

For Mail:

For HandBrake:

Devise your own as needed.


Workaround for the "Application First Launched" issue

As I mentioned previously, due to a small glitch in KM (at the time of this writing), the "focussed window" trigger conditions don't work when you first launch an application. Here's a quick workaround:

This workaround is for VLC. It will work with anything, though.

In a macro group with no conditions, I added this macro:

Then I changed the "Snap Palette" macro to add an additional "if" to the beginning:


That's it!

Let me know if you have any questions or issues.

11 Likes

Wow. This is terrific - amazingly helpful. Thanks very much

1 Like

Thanks for this wonderful macro! I've used it for a few months and find it most useful. I have one minor issue, sometimes when I switch quickly between two applications the macro does not seem to have time to finish. That's no problem in itself, but Keyboard Maestro issues an “Action Failed” notification when this occurs, which becomes annoying as it may happen many times during a work session of one hour or so. I've tried to adjust settings so that no error notification should be posted, but without success, and I wonder if this behavior is intrinsic to your “Snap Palette” action and if it's somehow possible to ignore errors and get rid of the notifications?

If the error message is coming from my action, then you have version 1.0 installed, not the most recent, which is version 1.1. One of the things version 1.1 added was "eating" any error messages, to avoid just what you're experiencing.

Install version 1.1 from the link below, but make sure you read the "Installation Instructions" first, especially the second bullet point about updating a previous version.

Let me know if you still have problems.

Thanks for your feedback! I've installed the new version now, and from my initial tests it seems to have solved the problem. I'll let you know if there are further issues.

Hey @DanThomas
Currently there is a have palette appear at the cursor's location option. Given you've got the palette's appearance relating to a window's position, could you have them related instead to the cursor's location? If we could set a palette's appearance location at a fixed x,y offset from the cursor's location, all sorts of options become available :star_struck:.

Assuming you already know about the option to have a palette appear directly underneath the cursor, I'm curious; what sort of benefits would a palette offset from the cursor offer that one appearing directly underneath doesn't?

Fixed palette locations allow gesture memory formation that shifting icons within current palettes break, for one. And what are keyboard shortcuts other than gesture memory :wink:? As my typing skills are weak and memory limited, I find keeping things on the screen to be easier. Also, distributing palettes circularly uses the space around the cursor more effectively.

Here's some ideas "around" :wink: this:

2 Likes

IMO, often the cursor is over a part of the window that you need to see/use in order to properly select a macro on the palette. Having the palette offset would allow you to see this critical info.

1 Like

Hey @DanThomas another thought on this. Can a palette be set anywhere relative to a window, e.g., if the window is a text or graphic document could a palette (be it icon or text) be fixed to a location on that document to function as a button/trigger in a HyperCardish sort of way?

Absolutely.

I'm not sure if those point to the current versions, so you'll have to do a little research.

Also see the token %FrontWindowPosition%

It's also possible that, by now, there's other ways to get a palette's position and move it, but these are what I've been using.

So I position a palette where I want it, then trigger a macro that gets the palette's position, gets the front window's position, and stores the offset in a variable.

Then when I want to reposition the palette, I get the front window's position and move the palette to the appropriate offset.

I hope that makes sense.

:flushed: it does kinda make sense. I’ll play with this. You are a good man DT, thanks!

Could the offset for palette positioning be relative to the current cursor’s position rather than the window’s position?

Yes, of course. It can be wherever you want it. It could even have nothing to do with any of that. I was just showing one example. :smile:

This is fantastic.
But...
The program I'm using (Finale) has some secondary tool palettes, and KM treats them as the front window.
So the Sticky Palette aligns itself with the tools instead of the main window.
Is there a way to attach the Sticky Palette to a specific window and not just the front window?
Does that make any sense?

I have been using your sticky palettes for a while now and I really love them. To be honest I would have to relearn many apps without them, so thank you. At the beginning I noticed quite a few "Action Failed" messages but at one point I carefully upgraded to 1.1 following your instructions and I thought that had solved all the problems. However, I do still get messages with some applications but they aren't 100% repeatable so it looks like a race condition of some sort and it might be out of your control. I will continue as is since it doesn't affect the functionality but I am passing on some of my error messages in case you might still be interested in looking into them.

2020-10-12 17:41:26 Execute macro “Snap Dynalist” from trigger Application “Dynalist” activates 2020-10-12 17:41:27 Execute macro “Snap Dynalist” from trigger The Focused Window Title Changes 2020-10-12 17:41:28 Execute macro “Snap Dynalist” from trigger The Focused Window Title Changes 2020-10-12 17:41:28 Execute macro “Snap Dynalist” from trigger The Focused Window Title Changes 2020-10-12 17:41:34 Execute macro “Snap Dynalist” from trigger The Focused Window Title Changes 2020-10-12 17:41:35 Assertion Failed: ActionCanFail(), file: /Users/peter/Keyboard Maestro/Project/Source/Actions/HBaseAction.mm:1029, value: 0 2020-10-12 17:41:35 /Users/paul/Library/Application Support/Keyboard Maestro/Keyboard Maestro Actions/Snap Palette to Front Window/Action.scpt: execution error: System Events got an error: Can’t get window 1 of application process "Keyboard Maestro Engine" whose name = "#Dynalist". Invalid index. (-1719)

This and similar ones happen after closing an application (Drafts, Dynalist, OmniFocus). #Dynalist is a macro group in KM and I thought that the window name in KM was always "Keyboard Maestro" from what I see in Script Editor?

A second kind of problem occurs when an Application is started:

2020-10-12 17:16:33 Execute macro “Snap Alfred Preferences” from trigger Application “Alfred Preferences” activates 2020-10-12 17:16:34 Assertion Failed: ActionCanFail(), file: /Users/peter/Keyboard Maestro/Project/Source/Actions/HBaseAction.mm:1029, value: 0 2020-10-12 17:16:34 /Users/paul/Library/Application Support/Keyboard Maestro/Keyboard Maestro Actions/Snap Palette to Front Window/Action.scpt: execution error: System Events got an error: Can’t get window 1 of application process "Alfred Preferences". Invalid index. (-1719)

I often get this error, but only with "Alfred Preferences" although it doesn't happen every time. This looks like a race condition.

Thanks for sharing, and thanks for the nice words. Yes, it's probably a race condition. I figure if it works most of the time, it's good for me. For example, there's some behavior with Finder that I really don't like, but I can't figure out how to fix it, so I live with it. Nothing's perfect, right? And I know you feel the same way - I'm just agreeing with you. :smile:

It's cool, how it work?