UUID AppleScript for Macro Groups - Does not work

I have the problem that it does not let the UUID of a macro or a macro group be called via AppleScript.
Can someone help me?

System up-to-date:

macOS High Sierra 10.13.8
Keyboard Maestro 8.2.4

Hey @appleianer,

In your vid you have a macro group selected rather than a macro, so your UUID does not point to a macro at all.

Therefore this error is quite understandable:

“Keyboard Maestro Engine got an error: do script found no macros with a matching name”

-Chris

1 Like

Thank you for the quick response @ccstone :+1:
I wasn't aware that I couldn't call the UUID of a macro group or the macros in it via this AppleScript.
I just wanted to handle the use of shortcuts.

Is this possible with another script?

Hey @appleianer,

It's not surprising that you cannot execute a macro group.

You can execute a macro via its name or its UUID.

What are you trying to do?

-Chris

I use a touch gesture with BetterTouch Tool to call the macro groups.
I have assigned a shortcut for each macro group. I wanted to handle this now with the AppleScript.

Especially for macro groups that can be called system-wide, that would save me some shortcuts.

Do you mean you want to select a macro group via AppleScript?

That's simple enough.

tell application "Keyboard Maestro"
   # By UUID
   select macro group id "0999F9D7-60E0-3476-83AE-FDFF5AC05C00"
   # By Name
   select macro group "Test Group"
end tell

If that's not what you want to do then please be more specific.

-Chris

Please excuse my expressions/formulations. For the English text I use an (online) translator.
I wanted to use AppleScript here in BetterTouch Tool to call the macro group on the desktop.

I didn't want to use the shortcut I usually use to open the palette.

With this script I can call a macro group within the Keyboard Maestro Editor, but not outside.

Hey @appleianer,

In Keyboard Maestro there is no such concept as calling a macro group on the Desktop.

What exactly are you trying to do?

Activate a macro group?

Or what?

Please explain.

-Chris

With this AppleScript:

tell application "Keyboard Maestro Engine"
	do script "C6ADF728-4358-4885-B0A9-70296E528B29"
end tell

It is possible for me to call the macro with a Launchbar or Alfred action.
Exactly the same I wanted to do with a macro group (here Palette) or a macro contained there.

As described in this article:

I just wanted to integrate the AppleScript into BetterTouch Tool.

As far as I'm aware, there is no way to activate a palette via AppleScript directly like there is to run a macro. I believe your best option is to create a new macro that uses the Show Palette of Macros action, have it show a palette for the macro group you want, and run that via AppleScript in BTT.

2 Likes

Thanks for your feedback @gglick :+1:

I also found a way to call macro groups via Launchbar. Since it is possible to call macro groups within the KM Editor with an AppleScript, I am hoping that @peternlewis will make this possible in a future version of KM via the KM engine :wink:

ScreenFlow

1 Like

I stand corrected. So what is this way you found to call macro groups via LaunchBar, in case someone else who finds this thread wants to do the same thing? I'm afraid that gif you posted does nothing to show us how to replicate your solution for ourselves, and thus isn't very useful apart from showing us that such a thing appears to be possible.

1 Like

Please excuse the gif should only be an example.
I found this workflow for LB and Keyboard Maestro on their website.
You will then be linked to this GitHub post.

I will gladly do a post in the next days, how I use this LB action with me.

1 Like

Thanks for the update and clarification. It turns out I actually have this same LaunchBar action installed, but was unaware it could be used with macro groups this way. However, when I tried it with an app-specific palette, it only gave me an "Activated" notification and didn't actually show the palette in question, so it doesn't appear to work for me the same way it works for you. At any rate, I look forward to your upcoming post.

I use a Typed String trigger "jh" to call Launchbar
To call the KM macros and group macros with Launchbar, I created another Typed String trigger with "jk". With this I trigger the following AppleScript:

tell application "LaunchBar"
	perform action "Keyboard Maestro Macros"
end tell 

KM-Macro%20Group_Launchbar

KM-Macro Group_Launchbar .kmmacros (1,9 KB)

The settings of the corresponding Launchbar action look like this:

Hey @appleianer,

Okay, let start by agreeing on nomenclature.

In general we think of running a macro as opposed to calling one.

A macro group cannot be run in any way, shape, or form, but if it has an associated trigger – that trigger can be activated (IF the group is available in the current context).

This works for displaying and hiding a palette for instance.

So.  The problem at hand is how to get all Keyboard Maestro macros (or triggers) available in the current context.

The Keyboard Maestro Engine exposes those via AppleScript like so:

tell application "Keyboard Maestro Engine"
   set kmGetHotKeys to gethotkeys with asstring and getall
end tell

The script produces a parsable plist.

The macro below parses the plist and produces names and UUIDs for the available items, which it displays in BBEdit (if the bbedit command line tool is installed) or TextEdit if BBEdit is not available.

As far as I can see this list is the same as what LaunchBar's Keyboard Maestro Macros action produces (although I'm listing both the name and the UUID).

-Chris


List Name and UUID of Macros and Groups available in the Current Context v1.00.kmmacros (7.3 KB)

1 Like

Yessss... Thank you very much. This is exactly the solution :+1::clap:

Now I don't need shortcuts for my macro groups anymore. I can now call it up with a BetterTouch Tool - Touch Gesture and also access all of the Pallets it contains. Faster and easier than with my launchbar workflow

Of course you can also call a single macro group in Launchbar or Alfred.

My thanks also go to @peternlewis for the introduction (KM v8+) of the "Show Palette of Macros" action :+1:

https://vimeo.com/286767794

2 Likes

I apologize for any misunderstandings caused by my bad English.
Thank you very much for your answers :+1:

@gglick has shown me a solution that works wonderfully. I solved my problem with the "more and more shortcuts" for myself.

For my part, I have programmed LB to run an AppleScript that tells System Events to execute a keystroke which corresponds to a KM hotkey that I have assigned to multiple macros. When the AppleScript fires from LB, the conflict palette is invoked. I wrote about this in my original post about activating KM macros via LB:

48%20AM

1 Like

Your article @BKammer was my inspiration for trying to call a macro group via BetterTouch Tool as well as in Launchbar.
This failed at first, however, until I got the tip from @gglick with this action

to try.

Since I always work with (conflict) pallets and sub pallets, I wanted to avoid the many additional shortcuts.

BTT

That's possible now. I saved 34 shortcuts just using BetterTouch Tool.

As an alternative to BetterTouch Tool I can now call my macro groups via Launchbar

CloudApp

1 Like