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

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.