Getting a list with modified macro info via JXA

I recently released MacroBackerUpper, which creates Time-Machine-like backups of one's macro library. But it works through a brute force method—it exports everything, does its analysis, then replaces identical files with hard links.

Just after releasing it, I stumbled across this forum thread: Getting Timestamp of Most Recently Modified Macro ... and something like the JXA scripts in that discussion would be very useful to me, as I could then only export (assuming I could figure out how to do that) macro groups that were modified since the last run.

Unfortunately, I know only a small amount of Javascript, and even less JXA. Could that script be modified to return these values?

  • Modification date/timestamp
  • Macro name and UUID
  • Associated macro group name and UUID

Also, where do you learn what things are available within JXA? I tried "groups" in place of "macros" in the above-linked script, but that fails. But I can't find a list of accessible objects anywhere—so how do you know what can and can't be used?

thanks for putting up with my stupid questions;
-rob.

1 Like

You parse the XML in the Keyboard Maestro Macros.plist file.

That's how I got the information I use in Macro Reporter:

1 Like

I see ... but that's all well beyond my talent level, unfortunately. Thanks!

-rob.

Run Script Editor and create a new document and make sure it's JavaScript:

image

Then select Window > Library and choose the KM entry:

image

That opens up the KM sdef dictionary which you can then explore to your heart's content:

As for JavaScript - it's only another programming language (yuk)!!

That's the same as the dictionary for Keyboard Maestro, right? (File > Open Dictionary.) I didn't realize that these were the terms that applied in JXA, too. Thanks.

Well, that would increase the list of languages I'm proficient in to ... one. :slight_smile:

-rob.

1 Like

I don’t know if there’s a one-to-one correspondence between the AppleScript and Javascript dictionaries since I’m not really familiar with the JAX side. Maybe someone who is can chime in…

You definitely had me fooled (maybe says a lot about me - hmmm.)

1 Like

I know just enough in a handful of them (python, perl, shell, AppleScript) to do what I want to do, most of the time. But the last time I wrote any "real" code it was in COBOL, way too many years ago :).

-rob.