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.
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.
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. 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.
I think this is probably the cause:
You have "Shows a palette until". Be default, it shows a palette.
You may change it to:
Or "Always activated and shows ...."
They will behave slightly different.
For me, I usually set here to be "Always activated".
I will do this:
Create another macro, name it, say "Finder Palette 2021 - Activate",
Add the action Show Palette of Macros.
Click the plus button, navigate to "Finder Palette 2021" macro group and click Macro Group "Finder Palette 2021".
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).
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.
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!
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. 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.
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:
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.
This is indeed what I use since I got this hint from my first related question.
This is something I need to check when I maybe have a little more time. It sounds and looks very interesting. Currently I am really happy with the solution I have gained thanks to your and other members help.
BTW: I forgot to mention that I also used KM for way more than three years before I stumbled over the awesome Palette feature through the great tutorials of @appleianer!
How about closing a palette whose names contains a certain term? I have a single macro that opens one of many palettes based on the front application, so the palette name varies. I'd like the macro to first check to see if one of its palettes is open, and if so, close it. The palette names all end with "(menu)"
I tried a bunch of stuff like this check for an open palette with a name containing the term:
tell application "System Events"
set theWindows to name of every window of process "Keyboard Maestro"
repeat with i from 1 to length of theWindows
set theWindow to item i of theWindows
if theWindow contains "(menu)" then
return theWindow
end if
end repeat
end tell
... but no dice because KM doesn't "see" palettes.
Since KM is handling the initial triggering of the macro, you could have it set the front application to a variable which is then passed to the AppleScript. So for example, if Safari is at the front, you could have KM pass the name of Safari's palette via a variable and then have the AppleScript read that variable to close said palette.
But.... this can likely be done natively with KM.
I have a similar macro that opens a palette based on the front application, and then hides said palette after I click an entry (or hit the ⎋ key, or 5 seconds of inactivity pass). You mentioned checking to see if a palette is open and then closing it... is there a reason you need to check first instead of just using the KM action Hide Macro Group?
Thanks @cdthomer - I'm not married to AppleScript here, but I'm still stuck on how to do it as you described with a variable and/or natively. The palette is determined with a Switch/Case action and a bunch of manual entries like this:
I made this a few years ago, and even though it's a little clunky, I've just added to it over the years by duplicating the group into a new "case" as needed for new apps.
Anyway, I don't know how to create a variable for the given macro group since it's set with a drop down list, and the ExecutingMacroGroup is the group the macro itself is in, not the macro group of the palette.
FWIW: This was a minor feature I wanted to add, but now I'm more curious than anything
So this is one way to pass the front app's name as a variable to AppleScript which can then use it to close the palette assuming the palette contains that app's name. I imagine since the palettes in question are specific to each app they should have some sort of naming convention that identifies them as such.
It works quite well for me in my limited testing but please let me know if it does or does not work for you!
----------------------------------------------------------
# Author: Chris Thomerson (@cdthomer)
#
# Current Version: 1.0 (Initial script)
# Version History: 1.0 (Initial script)
#
# Created: Saturday, January 29, 2022
# Modified: Saturday, January 29, 2022
# macOS: 11.6.3 (Big Sur)
# Tags: Keyboard Maestro, Palettes
#
# DISCLAIMER
# Permission to use, copy, modify, and/or distribute this
# software for any purpose with or without fee is hereby granted.
#
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
# WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
# THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR
# CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
# LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
# NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
# CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
----------------------------------------------------------
### Requires Keyboard Maestro 8.0.3+ ###
set kmInst to system attribute "KMINSTANCE"
tell application "Keyboard Maestro Engine"
set frontApp to getvariable "local__frontApp" instance kmInst --gets variable from KM
end tell
tell application "System Events"
tell application process "Keyboard Maestro Engine"
--pauses until the front application's palette appears
repeat until (first window whose subrole is "AXSystemDialog" and title contains frontApp) exists
delay 0.1
end repeat
--simulates clicking the close button of said palette
click button 1 of (first window whose subrole is "AXSystemDialog" and title contains frontApp)
end tell
end tell
(first window whose subrole is "AXSystemDialog" and title contains frontApp)
Your code works great after a slight tweak to test if the palette is open:
tell application "Keyboard Maestro Engine"
set frontApp to getvariable "local__frontApp" instance kmInst --gets variable from KM
end tell
tell application "System Events"
tell application process "Keyboard Maestro Engine"
--pauses until the front application's palette appears
if (first window whose subrole is "AXSystemDialog" and title contains frontApp) exists then
--simulates clicking the close button of said palette
click button 1 of (first window whose subrole is "AXSystemDialog" and title contains frontApp)
end if
end tell
end tell
Thanks so much! This snippet will help me beyond this one use
Hey @cdthomer, is this still working for you? I thought I would check before I go diving in to see why I am having a problem with this:
(first window whose subrole is "AXSystemDialog" and title contains frontApp)
Error:
System Events got an error: Can’t get button 1 of window 1 of application process "Keyboard Maestro Engine" whose subrole = "AXSystemDialog" and title contains "Keyboard Maestro". Invalid index. (-1719).
Yes it is still working for me. However, AppleScript in general has become very buggy as of late. See my topic below for an example of the issues I’ve had. So it doesn’t surprise me, unfortunately, that you are having issues.
I started to debug by inserting the always-helpful Variable Inspector Prompt action into the macro as various points.. As I moved the action down through the macro to isolate the action that was erroring - surprise - no error. Now it's working fine for the moment. Weird.