Create Pre-Filled Action - Comment Action With Auto-Completed Items

This is inspired by this recent Macro by @noisneil and uses basically the same method to create a pre-filled Action. (It also uses a method by @Martin to grab the macOS and Keyboard Maestro version numbers.)

It makes a Comments Action at the head of whatever Macro you are editing, automatically pre-filled with info about the Macro without you having to type in the date/time, macOS version, KM Version, Macro name and your own name as the Author).

I have searched for this before in the Macros section here but haven't found a Macro that does this so am uploading in case it is of use to others. (The trickiest part was editing the XML of the Comments Action to allow plain text and to be able to specify the text.)

I'm sure it can be improved! It is here as a of proof of concept to be adapted.

Create Pre-Filled Comments Action v1.06.kmmacros (32.6 KB)

Click to Show Image of Macro

7 Likes

That's a good first version you've made!

One improvement I'd like to see is this:

Right now your utility requires there to be an action already selected in the macro I am editing. But I'd like to run your utility when I've just started creating a new macro so there are no actions in it yet. In other words, just remove the need to have an action selected.

1 Like

Good point. That's done now. It should work if there are Actions already or no Actions already. And I've removed all the Global Variables apart from the one for "Author".

I've also simplified what the Macro is doing - it no longer tries to grab the version number of the Macro from the end of the Macro name. I realised this wasn't needed, especially in this generic version.

I've edited the first post and replaced with the new version 1.03

3 Likes

Thanks @Zabobon - that’s quick work! I also like very much getting rid of those globals. I’ll be having another play later on😄

1 Like

If I remember correctly reading the OSXSoftwareLicense.rtf file is the only reliable, on-system method of getting the actual name of macOS via a script, but parsing Keyboard Maestro's Info.plist file to grab its version number is not portable.

You cannot be sure of where Keyboard Maestro is on another user's system, so a fixed path is problematic.

tell application "Keyboard Maestro" to set kmVersion to its version
2 Likes

Thanks for that. I have updated the Macro with that AppleScript method for getting the KM version.

I also removed that last remaining Global Variable. The default "Author" is now just edited before first run, in the Macro itself.

And I've removed the Prompt Action as it's easier to type or edit the "Credits", "Purpose", "Instructions" text in the generated Comments Action itself. In fact, text from a previous version of the Comment can just be copy/pasted in.

I've edited the first post and replaced with the new version 1.06

4 Likes