Show/hide a palette by pressing/releasing a key

Finally I found a solution for something I always wanted to do with KM.

Show/hide a palette by pressing/releasing a key. This feels more natural to me than the default way. I find this especially useful when navigating text with the arrow keys. But it can be used for anything. This is the palette.

image

To open this navigation palette I press and hold "4". I chose this key because I can reach it blindly with my left index finger. The rest I do with my right hand. "j" = left arrow, "k" = right arrow, etc.

The palette is visible as long as I keep "4" pressed and disappears when I release "4". So I don't have to choose between "show for one action" and "always visible".

If someone wants to try this, these are the triggers.

Show palette

Hide Palette

The "intermediate step" (shortcut ⌃⌥⇧⌘+V) seems necessary to me because palettes can only be displayed/hidden with "is pressed".

For the trigger of the arrow keys I have chosen "is down" so that I have key repeat.

Of course you can also use the mouse as long as "4" is pressed. And possible are also "typed string triggers" or others.

Unfortunately I had to sacrifice the "4" key for this. But I can live with that. When I need it, I press fn 4.

Glad you solved it - although it would drive me crazy to lose being able to type "4"...

A few suggestions:

  1. As your first two Macros do the same thing but just have alternative triggers you can combine them into one Macro.

  2. Instead of having the Macro press a key combination like ⌃⌥⇧⌘V to show/hide the Palette you can use the Keyboard Maestro Action to show/hide the Palette.

  3. Instead of using the "4" as your trigger key why not use the Section Sign key § which is on the extreme left of the number keys?


Show Hide Palette.kmmacros (2.4 KB)

  1. In the Group of Macros that you are show/hiding you should set the Group to Shows/hides a palette when: (as this will only have the Macros active when the Palette is showing) but then you can leave the hot key field blank:

3 Likes

Thanks @Zabobon Your solution is of course much better, I will try that. :grinning:

§ is unfortunately not an option because I can not reach this key blindly.

1 Like

I downloaded your macro to test and replaced "4" with "6" and deleted the v shortcut. But it does not work. Do you see an error somewhere?

I can see that your first Macro is show/hiding a Group called "Navigation" and your Palette Group seems to be named "Palette Navigation"

I noticed that too, but the other group doesn't exist in the list. There are even more groups missing.

Anyway, I united the triggers on your advice and stay with the shortcut. That works fine.

Thanks for your help @Zabobon :slightly_smiling_face:

If you keep scrolling down or up the list, you should find it. The list seems to be divided into two alphabetically ordered parts (I think to do with whether the Groups are enabled or not).

That's right, I found it. The sort order is ... beyond my comprehension.

But it still does not work, unfortunately. I also tried with other palettes, without success.

Did you try your macro with one of your palettes?

Yes, it works fine for me. Here are the Macros and Groups I used for testing. When they import in, you need to enable the two Groups.

Holding and Releasing "6" shows/hides the Palette and when the Palette is showing, tapping L,R or U runs the Macros (they just display text in the test).

Test Group and Other Macros.kmmacros (6.6 KB)

Is this the kind of thing you are aiming for ?

Well, yes it is about navigation with the arrow keys. Or what do you mean? :slightly_smiling_face:

Simply that there are (non-KM) routes to setting up fairly universal vim bindings.

With karabiner, yes, thanks for pointing it out. I would certainly do that if it would not work with KM. But it works very well. @Zabobon just helps me to open the palette differently. :sweat_smile:

1 Like

Weird. I have set everything up again and given the group a different name. Now it works! Thanks @Zabobon :smiley:

1 Like

@Zabobon May I ask for your expertise one more time? Or of course the expertise of someone else. :slightly_smiling_face:

To my global navigation palette I have added two app specific ones. These are only displayed when the right app is in front. This works fine. What doesn't work is moving the mouse to the palettes and back to the original position when "4" is released.

Obviously I am doing something wrong. Can anyone help? Thanks a lot!

It is not working because the mouse position will be recorded and restored when you press "4" (as that will run the whole Macro). And when you release "4" the Macro runs again and basically stores and restores the mouse wherever it is.

Also, a Local Variable to store the mouse position won't work as it only lasts for a single Macro run (and you are running the Macro a second time when you release "4").

So, you need to use a Global variable (any name without "Local" in it) such as mouse_position

You need to only store the mouse position if the "4" key is down.

You need to only restore the mouse position if the "4" key not down.

Show Hide Palette.kmmacros (3.1 KB)

Ok, I understand your explanations (to some extent :smiley:).

But I had to add an action to move the mouse to the palettes. Is that the way it is intended? Anyway, it works exactly the way I want it to.. :champagne: Thanks again for your great support!

1 Like

You probably know this already, but there is an option to make the Group Palettes appear where the mouse currently is.

This is the exact opposite of what I want. The palette opens where the mouse is. But I want the mouse to go where the palette opens. :slightly_smiling_face:

I don't know if there's a way to do that "natively" in KM, but you can use some AppleScript. This demo pops the "Menu Glyphs" palette (from the Macros Library), uses an AS to grab the top-left corner coordinates, positions the pointer to an offset of that (on my machine, hallway down and halfway across the palette), then uses another AS to pause while the palette remains open. It'll then return the pointer to the original position.

Main advantage is that you aren't required to keep your palette in a fixed position.

Palette and Position Test.kmmacros (5.0 KB)

Image