Close Palette by Name?

Thanks to @martin yesterday I created a bunch of new palettes that really enhances my workflow.

One little issue I recognized for a long time but didn't ask about because it only affected just one or two of them is that after the system start all Palettes are showing up once and I have to close them manually. Now in ideal case I'd like to create a small macro that closes them all i.e. after the system start. First of all I am not sure what trigger to use. Might this be the new "System Appearance" trigger?

I know that if there is just one Palette open I can use ESC to close it. But that works just once for one of it open, so a sequence of more ESC presses does nothing after the first close.

I took a look at the action "Cancel a Specific Macro". But first of all it seems that an open Palette ain't handled like a Macro and second even though I read all the examples for "Cancel a Specific Macro" I think I have to study development first because I still don't have a clue what to insert in the "Instance" field. I even tried to work with the given examples (including setting the Variable etc.) but wasn't able to literally cancel "my specific" test Macro.

Wouldn't it be possible (and great) to simply target this command to the name of a Macro or Palette or am I missing something easy here?

Hi @Hans-Peter_Henkel,

Glad it helps.

I don't know if other palettes would do this or not, but Global Palette is the only palette I know of that will show up at system start. For this reason, I don't use the Global Palette except for testing purpose. I removed the global palette trigger after testing.

Let me show you how I do it.

I have a macro shows me different palette depending on the front app.

Here is the beginning of the macro:

click to see screenshot of part of the macro

Explanation:

  • The Semaphore Lock action ensures that only one instance of the macro is running.
  • The %Application%1% token will return the front app.
  • I use the Switch/Case action to show different Palette of Macros depending on the front app.
  • With the same front app, we can also let KM show different Palette of Macros depending on different front Window.
    • As shown in the screenshot above, I make KM to show the BTT - Screenshot Editor macro palette when I'm editing the screenshot I took with BTT. Elsewhere, I make it to show the other macro palette.

Set up a trigger for the macro, and that's it.

(I remapped the Right ⌥ key with Karabiner-Elements and use this key as a trigger for this macro. I use it so often that I want the hotkey to be most easily accessible. Right ⌥ is my least used key, so I remapped it for this purpose. I remapped it to Mouse key 20. Then I could also make combination hotkeys with , , and to trigger other non-app specific macro palettes.)

Let me know if anything is unclear to you.

1 Like

One way of doing this would be to use a simple AppleScript that closes the palette via Systems Events.

You can just plugin your palette's name in the line set paletteName that way it ensures it closes the right one.

Repeat this script for each individual palette, OR let me know if you want one script to close multiple palettes, and I can show you how that works too.

Granted, there's probably better ways of doing this, but this is the method I know. :sweat_smile:

----------------------------------------------------------
# Author:			Chris Thomerson
# Version:			1.0
# Version History
#					1.0 (Initial script)
# Created:			Wednesday, November 3, 2021
# Modified:			Wednesday, November 3, 2021
# macOS:			11.6.1 (Big Sur)
# Notes:			
# I claim no responsibility nor guarantee compatibility
# As with any kind of custom scripts, these must be tested thoroughly on each person's device
# May be used and distributed freely
----------------------------------------------------------

-- You must put the name of the palette you want your script to closer in the quotation marks
set paletteName to "INSERT YOUR PALETTE NAME HERE"

tell application "System Events"
	tell application process "Keyboard Maestro Engine"
		click button 1 of window paletteName
	end tell
end tell
2 Likes

Thanks a lot again @martin for sharing your great example.

I also don't use the "Global Palette". Currently (kind of a bit inspired by the new KM version) I created just a bunch of new Finder Palettes giving me quick access to things I use quite often. I even managed a "nested" Palette, triggering one from another one. And all these Palettes are set to be "Available in these Applications" > Finder. But they are open after every system start automatically for some unknown reason.

Your example is awesome and shows your "pro level" but I am one of the "dummies" who don't have that much skills in this field. I mainly use KM with simple triggers and actions but also quite intensive on the other hand. But when it comes to Token, Variables, RegEx and things like that I am completely out of the game in most cases. Which might not only be caused by missing skills but the lack of time to practice and get more into it.

If I'd like to adapt my existing Palettes to your "system" it would probably work and help but it would take too much time to do it. Especially right now where I have quite some projects going on in parallel. I have a lot of other Palettes for other applications which I trigger with specific trackpad gestures using Better Touch Tool which works quite good.

I just wondered if there is an easy way for a fool like me to call a Palette by its name and say "please close". :wink: If it ain't, it's not a big deal. If it bothers me too much during time I might just create a shortcut using a mouse click on "Found Image" to close them quickly, one after another.

I hope for your understanding and really appreciate your help. Thanks again!

1 Like

Thanks so much @cdthomer for your example script.

I am unfortunately not the advanced user working with scripts and don't have any programming skills nor the time to get some. As already explained more in detail in my previous post as an answer to Martin I was searching for an easier way for such an (IMHO) easy task.

I also ask for your understanding that I am a bit overwhelmed with this pro-level approach but nevertheless like to thank you again for your kind help. :+1:

No worries! I am not really an advanced user myself to be honest. And literally everything I know about AppleScript I learned here from the real experts, and really just during the last couple of months. So it's not too complicated to get the hang of it if you want to tackle it.

Again, if you have questions, feel free to reach out because I certainly understand what it's like to feel overwhelmed hehe :grin:

-Chris

1 Like

Simple and useful. Thank you!

1 Like

Thanks again Chris (@cdthomer) for your very kind reply. :smiley:

This is also the right time to thank all members of this forum for being that kind especially with less experienced users regarding scripting, coding and what else. I know a bunch of other forums where the overall "tone" is quite different, to say the least.

Cheers, HaPe

2 Likes

In case you weren't aware or if you need a reminder, there is an action for this. Reveal Macro Palettes/Conceal Macro Palettes/Conceal Macro Palettes until Application Switch. There are many iterations of utilization. I made a simple toggle switch that works fantastically.

KC

3 Likes

First time being described at "pro level". :laughing:
Before I bought KM, I knew almost nothing about scripting. I have learned so much since then. It did took me a lot of time, but it's worth it. I can work with most simple stuff with a degree of comfort and confidence.

Don't be shy to post your questions. The more specific, the more likely you can get a working macro that solves your problem rather than conceptual steps or a general macro.

I still don't know why the non global macro palette would be triggered at system start, assuming you don't have login trigger. Here you can tell I'm not a "pro level" user at all. :grin:

Here we may need to call real "pro level" users like @ccstone or the master @peternlewis.

It's nice to have a workaround solution, but it would bother me so much that I want to find out why and remove the trigger.

1 Like

Thanks a lot @kcwhat. Indeed I wasn't aware of this actions. I tried to use them to reach my goal and with the very first system start after setting up the action it seemed to do what I wanted to. Unfortunately this avoids the ability to open my Palettes afterwards with my regular macro. This seem to be a permanent command which has to be deactivated using the "Reveal…" action.

Things I tried:

• use "Conceal Macro Palettes" triggered with "Engine Launch" (divided with a Pause of 10 sec.)

Result: the Palettes disappear as expected but didn't show when they should with my regular Macro.

• created a dedicated Macro Group with a Macro using the action "Conceal Macro Palettes" inside
• created a Global Macro and used "Activate for one action" triggered with "Engine Launch" (divided with a Pause 10 sec)

The result is unfortunately the same.The Palettes disappear but won't open again.

I use mine as a toggle, on my StreamDeck, to conceal and reveal all the time. It depends on the application I'm in.

Hi @Hans-Peter_Henkel.

Can you post a screenshot of at least one of the macro palette that would open at system start?
It might be easier for others to see what is going on.

Select the macro and use "Copy as Image" from the menu. Then paste it to the forum.

image

This will include the triggers in the image as well.

Sometimes, the macro group settings may also affect the behavior, so including a screenshot might also be helpful.
image

1 Like

You know, it's all about relativity. From my perspective this is "pro level" and gents like ccstone or the master are simply not from this world. :joy:

I know that it would be worth the time to investigate and get better skills. Unfortunately the days have just 24 hours and that is not enough for me. :wink: If only I could, I would… but I am already happy what KM can do for me, even on a "non pro" level.

Thanks again and I will try to get forward with this trying to keep the balance between benefit and effort.

1 Like

Thanks @martin for your help. I needed to restart again to check.

As follows the Palette that shows up last on top of all the others that are configured like this.

image

And here is the Global Macro Group from within the Macro is triggered.

image

Thanks again.

And BTW: even this icon shows up after the system start.

Hi @Hans-Peter_Henkel,

I think this is probably the cause:
You have "Shows a palette until". Be default, it shows a palette.

You may change it to:
image

Or "Always activated and shows ...."

They will behave slightly different.

For me, I usually set here to be "Always activated".

I will do this:

  1. Create another macro, name it, say "Finder Palette 2021 - Activate",
  2. Add the action Show Palette of Macros.
  3. Click the plus button, navigate to "Finder Palette 2021" macro group and click Macro Group "Finder Palette 2021".
  4. Set up a trigger and you are good to go.

I have done the first two steps for you. Please download the macro below and do steps 3 and 4. (I don't have the macro group; therefore, you have to do step 3 on your Mac).

Finder Palette 2021 - Activate.kmmacros (1.2 KB)

1 Like

I respect all of the contributors on this forum. There are several superstars at different levels of acumen. You never know who/m has figured out what and when. The beauty of it all is, we all utilize Keyboard Maestro in different facets based on our needs. Pro Level is relative to the problem and subsequent solution. So solutions may come from @ccstone one day, @gglick another, @tiffle dropping a gem or even YOU tomorrow. JMichaelTX's contributions continue to help me (and many others) to this day. The fact of the matter is that people come here to help, with suggestions, based off of their experience and usage. There are a ton of processes that I employ that some of the superstars wouldn't think of and vice versa. I do agree that @ccstone is at a scripting/regex level that I dare not step in. I'm just glad that he and many other are here to share their expertise. I appreciate all Keyboard Maestro contributors. When helping others, everyone here is or will be pro level at some point.

KC

KC

6 Likes

I couldn't say thanks enough @martin!

Just this did the trick. I followed your instructions and used your Macro template. It worked for this particular one first like expected. But then I changed the recommended setting to all other Palettes that showed up in parallel and they also didn't appear any longer at the start. In the meantime I figured out that even a user log-out and back in was enough to test the behavior.

Now all is working totally to my liking, the Palette shows up with my macro, disappears with the selection of one entry and does not show up with the system start!

You guys are awesome! Thanks again so much everyone! :+1: :+1: :+1:

2 Likes

Thanks @kcwhat, I totally agree with you. I just wish I'd had more time to learn and practice different things to just sniff a bit more of the "pro air", of course still on a very low level. :joy: Maybe some day, when it comes close to retiring.

JMichaelTX also helped me a bunch of times. So sad that he is no longer with us. He really was one of the most ideal examples of a real pro that didn't have any problem to help even the newest members with hardly any knowledge at all with as much patience and kindness as possible.

Thanks again and have a great day!

3 Likes

You're very welcome!
I'm glad I could help out and make you happy.

There is another action you could try:

There are a few options to this action as well:
image

Using this action and the one I had in the uploaded macro will be different.

With this action, I believe the appearance is what you've set in the macro group settings.
For instance, I have a macro palette using this action and set up its appearance to show icons only:
image

I will use mouse click to trigger the target macro.


For the majority of the palettes, I prefer to use this action:

because the palette uses the Conflict Palette style, and I can use keyboards to trigger the target macro.

I did not know how to utilize the macro palette until very late (like three years later after I began to use KM). My workflow completely changed since then. No more numerous hotkeys to remember anymore. As I've shown you in my first reply, I need only ONE hotkey for most of my works.

2 Likes