How to Parse the right Macro UUID out of the KM Macros Plist File for external Script call using AppleScript?

Jumping in here... I've been busy on other things, so I haven't been on the forum recently.

I tried to skim this thread to see what you needed, but I'm not patient enough, I guess. If you can summarize what you're trying to do, I might be able to help. I'm really good at parsing plists, using JXA.

1 Like

Here's one approach.

(You can fine-tune the details of the XQuery)

XQuery listing of KM Macros by name with UID.kmmacros (8.6 KB)

1 Like

Hi Dan

love to see you replying here !!

I was very busy the last weeks on an amount of other things I had to do, too....

I don't know If you've had the Time to read this thread and and think about what I am after....

I'll try to wrap up this for you in a DM because I think you can really help me out at some point - see you there

Greetings from Germany


1 Like

Hello Rob (@ComplexPoint)

first of all I hope you don't mind that I use your RL name.

I've read and seen a lot of stuff you did here in the past and I love the almond of skills you have

I like your approach combining JXA and XQuery (don't know anything about XQuery but its on my things I'd love to learn in the future) - but since I am trying to learn JXA it is hard for me to understand your code - but I try.

From what I understand - correct me If I am wrong - It lists ALL Macros whether they are enabled or disabled. but this is only one part of what I would need to have - if I would use your code.

Since this approach refers to my Idea grabbing Macros Automatically in a Spotlight Search Macro for the given App that is at front in conclusion with Apps whose are running in the background that I use in the intercommunicative way together - I need to have a Script that looks for

  • uses the Group Name or multiple ones
  • only the enabled Macros
  • strips out the Macro which uses that Script
  • lists them line by line in MacroName=MacroUUID

Why this is needed ? Because I have a lot Macros & Groups in My Setup whose Enable only those that are needed and Disable those that aren't needed in a conditional manner including even the check on which Mac they are running or are needed.


That is for this.... speaking now of AppleScript and the Basic Idea parsing out the MacroUUID defined by The Group's Name and the Desired Macro's Name as iput for the code that has to do the work giving me the UUID.

Do you eventually can help me there ?? - If so please consider that I want to put the code in a Handler for a Script Library.

Greetings from Germany


This is the bit I still don't understand. Why do you need the UUID? If you know the name, and the name is unique among your currently enabled macros, you can use the name in kmtrigger[1]. If the name isn't unique among your currently enabled macros, how do you chose the correct item from a list of names?

[1] This was after some very quick tests, so I'm quite happy to be corrected if, somehow, kmtrigger triggers both enabled and disabled macros

Hello Nige

In this special Case The format has to be set like this due to the Original Code of Dan's Spotlight Search Prompt Macro which can be set up by Hand for a specific use case or should be grabbed by the use of a Script.

Greetings from Germany


I might need to ask for a translation of strips out there. Select ? Delete ?

Broadly, it sounds as if you need a function of the general type:

GroupNames -> MacroName -> [Matching UUIDs]
[String] -> String -> [String]

The output value will inevitably be a list of matching UUIDs, because the KM architecture doesn't exclude name-sharing among groups or macros.

The XQuery above:

  • doesn't filter on a subset of MacroNames (but could be adapted to, with a WHERE clause)
  • doesn't filter out disabled macros (I forget whether enabled status is represented in the plist, but I think it probably is, so the XQuery could, again, be adapted with a WHERE clause)

Once the function returns a list of 0, 1 or several UUID matches, then you will need some kind of UI or principle for:

  • reporting non-matches
  • using unique matches
  • choosing between multiple matches

Have I got time right now ? Possibly not for a while.

But you might be able to do it yourself with the help of:

The XQuery Book

(bear in mind that we are using XQuery 1.0 here)

Hello Rob

whether Selecting or Deleting is the thing here.....

to clarify what I mean lets say your code is adapted to only one Macro Group

  • Your Code puts out a List in format Name=UUID

  • My Macro based on Dan's Spotlight Search Prompt will be listed, too => because my Macro is also in the Desired Macro Group.

    • this is the scenario I want to avoid. The Macro should just be stripped out of the List that is generated by the Code.

That would be the the part where I would need your help ....

That's odd .... but that's Life....

Thank you for pointing me to the Book

I for my self have not much time at the moment for learning more stuff.... but probably in the future...

Greetings from Germany