Deciphering a kmmacros plist file

I’ve been searching, reading, and studying, waiting for the “aha!” moment to occur, and it just hasn’t happened. So let me ask just a couple of questions:

  1. In AppleScript, how do I get the names of all the Macros (or the only Macro) in a .kmmacros file?

  2. In AppleScript, how do I get the names of the Actions used in one of those Macros? If not names, something useful. I just can’t figure out the access path, and I’m hoping the answer to this question will turn the light on. Hope. Hope.

If someone could help me here, I would be eternally grateful, or at least slightly appreciative. Thanks.

Hey Dan,

That gets pretty complicated.

set macroFile to "~/Documents/Keyboard Maestro Stuff/Exported Macros/Test Group Macros.kmmacros"

tell application "System Events"
  tell property list file macroFile
    property list items --> examine
    name of property list items --> examine
    properties of property list items --> examine
  end tell
end tell

-Chris

I don't know if you were being sarcastic or not, but to a man with no Rosetta Stone, yes, it is.

I don't know what "--> examine" means. I'm guessing your didn't mean I should just run this script (after changing the file name), because it lists a whole lot of stuff.

Hey Dan,

I don't like sarcasm and try not to use it.

Yes I did mean to run the script, and examine each step.

There's no convenient way to scarf up keys from nested items, so you have to know what you're working with if you're going to use System Events.

I'm sure there are tools for working with XML that have far more intelligence, but I haven't fought my way up to proficiency with any of them.

-Chris

Hmm, I'll have to remember that. I use sarcasm all the time, although if I use it in written communication, I try to make it obvious. Still, it might sneak in by mistake. I hope not.

OK, here's the thing. I get what you're saying. I'm a developer, examining things is how I learn. But AppleScript isn't a programming language, it's an attempt at some hybrid language, and I'm so lost in it I have no idea how to do anything.

If there's such things as classic objects with properties that can be examined using a debugger or the like, I haven't discovered it. There's no "object.property", or an obvious way to examine an object that's a child of another object. There's things like "properties", "attributes", "content", "value", but I have no idea what's what, and even if I did, I wouldn't know what I'm seeing, because everything gets printed out in some supposedly human-readable form that is usually fairly indecipherable to me.

When I do Google searches, the answers rarely help me, because they usually show how to do the thing being talked about, but they don't tell the "how it works". And they're talking to non-developers who have no preconceived ideas.

What I need as a "Guide to Using AppleScript , translated into Developer-Speak".

Hey Dan,

Download the Script Debugger 5 demo, and you'll see a different world. (Script Debugger 6 is scheduled for release soon.)

Once you have that running run this script:

tell application "System Events"
  set sevPath to path to it
end tell

tell application "Script Debugger"
  open sevPath
end tell

Examine the property list file and property list item classes.

Script Debugger is fairly expensive, but it's a total game changer if you use AppleScript.

When you run a script you can step through, set break-points, etcetera.

Result views are Best, Source, and AEPrint.

Use Pretty Print in source to see a good text outline of the result.

Use Best for a structured GUI view.

Feel free to ask me any questions you might have.

-Chris

Hey Dan,

There's nothing wrong with a little humor, but genuine sarcasm is a different beastie.

Origin of SARCASM from Merriam-Webster Unabridged Dictionary:

“French sarcasme, from Late Latin sarcasmos, from Greek sarkasmos, from sarkasmos, from sarkazein to tear flesh like dogs, bite the lips in rage, speak bitterly, sneer, from sark-, sarx flesh; akin to Avestan thwarəs- to cut”

In my experience real sarcasm is usually poorly concealed hostility, and that's why I try not to use it.

--
Take Care,
Chris

Wow, do you have a window on my past or something? Yes, for a long time I struggled with that very thing, until I spent a lot of time dealing with anger management. It still crops up once in a fortunately rare time, but as I said, it's rare.

So I should have said "were you joking?".

I'm watching some videos now, and if it continues as I suspect it will, $200, while expensive, will be completely worth it.

Thanks. You may well have proven yourself a life-saver. OK, that was hyperbole... but NOT sarcasm! :stuck_out_tongue:

OMG! “Script Debugger” is a terrible name for an awesome product. It’s so much more than a debugger - it’s an IDE!

Best. Money. Spent. in a long time.

Hey Dan,

Outstanding!

Happy scripting.  :sunny:

-Chris

1 Like

Wow, I noticed only now that the new Script Debugger 6 is $100, that is… 50% of the old price!

I think this time I’m going to purchase it … finally…

2 Likes