MACRO: [KMFAM] Favorite Actions and Macros v1.4 Released 2021-12-09

thank you very much Dan for your prompt and detailed answer.

I edited the select favorite action.html file with Bbedit.

  • I changed the var width to "1100" and the width is now perfect !
  • the right border of the corresponding action is truncated. It's not the end of the world, but is it possible to find a way to preserve it ?

thanks again VERY much !

Screenshot (click to expand/collapse)

Glad that worked!

The image portion shows the image as it was captured. So the wider your KM Editor's macro panel is, the wider the image will be (and visa-versa).

You could change the width of the image pane. In the same file, around line # 64 is this:

#actionImageCell {
	width:485px;
	max-width: 485px;
}

You can change that to wider, but of course that takes away from the size of the pick list on the left.

When I have a macro image that's too wide, and I actually care about it (which is only sometimes), I'll resize the KM Editor's macro panel and capture a new image. The screen that lets you add a new macro also allows you to only update the image, if you want. (I hope that makes sense).

1 Like

This is simple and would be my first choice. I understand about resizing the KM Editor macro panel. Sometimes it works and sometimes not. I also tried the "update image route. "For example the action "comment" is very fickle. Usually too big even after adjusting the macro panel which I made tiny. The actions are squeezed in.
All in all, 99.99999% success and I am extremely grateful.

1 Like

Would there be a way to batch import about 30 of my favorites into KMFAM ? thank you

No. I have code to go from KMFAM to KM's native favorites, but not the other way.

You might consider migrating favorites as you need them. But even if you don't, it doesn't really take that much time. I'd imagine you would get in a rhythm.

2 Likes

you are absolutely right. that's what I will do. Thanks again Dan !

1 Like

Wisdom.

This is the kind of thing I would spend hours on to automate 10 minutes of manual entry :joy:

3 Likes

Oh for sure - me too. Absolutely. LOL.

2 Likes

I thought I would share something I've built for myself as a sort of 'plugin' for KMFAM (by the way - KMFAM is truly an invaluable tool I use all the time). It's rough around the edges and not yet in a state to share easily, but I thought you might be interested.

Problem: I use KMFAM to paste a set of actions I use as a template for containing and executing python from within KM as a submacro. I have several dozens of these. There's a non-negligible amount of time spent configuring this template for each new script I create. This consists of renaming variables, including in the debugging / documentation text boxes / error text boxes / results notifications text boxes. With all things KM, why not automate it?

In short, I wanted a way to configure the template stored by KMFAM with minimal effort (although I have probably spent a little more time making this than I will save using it in the future LOL). Here's an example of what my python script subroutine macro template looks like - note all of the placeholders in the texts:

Macro template actions

My solution is a subroutine macro that uses python in two possible configurations:

Configuration A: Add replacement tags

I execute the macro standalone, which configures it to launch a NiceGUI native window. This allows me to define replacement tags in each of the sets of actions saved to KMFAM

After saving, it appends a new key-value to the action's json object in the KMFAM as 'replacementtags', the value being an array of these text strings that are defined here.

Configuration B: Intercept

In the KMFAM 'select' macro, I've edited the control flow so that if an action's name is detected before pasting, it is run through my submacro first.

  • If the action has no associated replacement tags defined, or we don't define anything to replace tags with, nothing happens, and we paste the actions as usual
  • The script looks for an object with the associated name. If found, and if the action is found to have tags defined, another NiceGUI window appears allowing us to define what to replace each tag with when we come to paste it.
  • Pressing save saves the modified XML to a local variable which is then pasted instead of using the KMFAM applyAction. The underlying XML in the favoruite's JSON is left unntouched; the modifed XML is also used for this individual sequence of actions.

Here's what this configuration's window looks like:

And how I modified the KMFAM actions:

Modified KMFAM Control Flow

Keyboard Maestro Export

Happy to share details if interested. There's nothing inherently complicated about this, especially compared to the code for KMFAM itself. I will note though that replacing text held within any sort of 'display text' box took a bit of figuring out. In short - these seem to contain encoded versions of the text within their data tags in the XML, presumably because they also include encoded styling. KM always defaults to using the encoded text vs the plain text contained in the action XML if available. The solution was pretty simple - using a greedy regex to capture and then delete anything between found data tags first (although presumably this means you can't use styled text with this tool, I haven't tested it). KM then falls back to using the text in the string tag, which is what we modified.

If others show interest in sharing this then I might have to reprogram this to use a native HTML Prompt window and clean up the UI first. I used NiceGUI for practice given I'm building something else with it at the moment, and installing that is a little more involved vs just sharing a macro.

Also, if Dan wants to build this (type of functionality*) into KMFAM natively I would be happy to help in any way I can.

It looks like you've done some amazing work here. Honestly, it's a little over my head, believe it or not. But I'm thrilled you got something like this working.

But no, Dan will not be building this into KMFAM natively. :joy:

I think almost all of us have one or two (or dozens) of macros that fit this!

3 Likes

But no, Dan will not be building this into KMFAM natively.

Honestly I'm relieved to hear that, but only because I got halfway through writing this post about this tool I had built, realising I hadn't actually checked to see if you had implimented similar already and couldn't bare to look :woozy_face:

Oh, man, do I know that feeling! Along with the one you get when you've spent days and days (or longer) on something, only to have someone come along and say "You know, there's a built-in way to do that..." Definitely forehead-smacking time!

1 Like

Let us not forget the times we search the forum for something and find our own previous post with the same question.

4 Likes

That has happened to me multiple times!

3 Likes