Question about Pasting XML Into the KM Editor

@peternlewis It used to be that we couldn't paste KM XML for actions, macros, or groups directly into the editor. We had to set the proper clipboard type, like com.stairways.keyboardmaestro.actionarray, com.stairways.keyboardmaestro.macrosarray, or com.stairways.keyboardmaestro.macrogroupsarray.

Now we can paste plain-text Actions XML. Nice.

But we can't paste plain-text Macros or Groups XML. Any plans on changing that?

Secondly, and I don't know the right way to word this, you've possibly changed how the XML needs to appear when pasting in XML for Macros, when using com.stairways.keyboardmaestro.macrosarray. For instance, if I use "Copy as XML" on a macro, and put it back on the clipboard with the proper clipboard type, it won't paste back in. I have to remove the enclosing Groups before it will paste in.

It didn't used to be this way, I don't think, although I suppose I could be wrong. But in any case, it would seem to me that if I used "Copy as XML", I ought to be able to paste that back in just like I can with actions.

What do you think?


I'm always learning things. I don't think I ever noticed that "Copy as >" pop up menu item on macros. In fact, I don't think I even noticed the "Copy as XML" option in the cogwheel of an action, even though I use that cogwheel a hundred times per day. I must have tunnel vision, seeing only what I want to see.


No particular plans, no.

There is no one XML format for a macro. There is different XML formats for the macro when referenced in different ways, and they aren't interchangeable. Some variants include the parent macro group information and some do not, depending on the required context.

Generally, if the purpose is for export, then it will include the groups and otherwise will not.

The various com.stairways.keyboardmaestro.* flavors are internal flavors, subject to change, and if you want to put things in there then I'm afraid you're on your own for ensuring that the format is correct - I don't keep track of the various formats or document them because the code handles what it needs to handle.

If you want to copy a macro, copy the macro. If you want to preserve that, save it to a Named Clipboard (though this is still subject to change just like the saved clipboard of a graphic program object might stop working if you update the program).

I believe that's brand new to Keyboard Maestro 10.

Not new.

It's always a good idea to review application menus and contextual menus once and a while – particularly when a new version comes out.

The Edit > Copy as menu has been there for a long time, and as you can see I've assigned some custom keyboard shortcuts:


The Action CogWheel/Contextual-Menu options have been there quite a while.

That’s true for everyone from time to time, although in my experience it tends to get a bit worse as people age...

Dammit!  :sunglasses:


I want to clarify what I'm getting from your statement. It sounds like if we want to build macros programmatically, we're doing something that you don't officially support. Is that right?

Anything that uses XML is at the edge of support. At some point in the future, Keyboard Maestro may entirely change its storage system and XML might not be supported or might change entirely.

Creating macros based on XML via AppleScript should continue to work for the foreseeable future, but the exact format of the XML required is whatever the exact format of the XML required is, it is not something I specify.

And the clipboard flavors are similarly whatever they are and subject to change.

So it is not a question of whether I support them - they are supported in the form that they are, but I don't document the XML (and frankly don't really know what the XML is without looking myself) or ensure that the XML does not change from version to version.

Dammit, Peter, I was all set to argue with you, and then you go and say something I totally agree with.

I will ask this, though. If you ever decide to move away from the XML, I'd appreciate it if you could let me in on it beforehand, perhaps even be on the beta-testing program (but I only want to do that for something like this). I have a crap-ton of published macros that will break, which is on me of course, but I'd like the chance to mitigate as soon as possible. Thanks, and I know there are no promises, but I thought I'd put that out there.

1 Like

Seeing people argue is usually exciting. Seeing people agree is a little boring. :slight_smile:

Change is usually good, when it's planned by people. I'm not good enough of a programmer to read between the lines here to figure out what might be coming, but I'm drawing the inference that KM may store its data in a database in the future so that it becomes more efficient at data storage. I think the main benefit (for me) will be that the KM Editor will be much speedier. I look forward to that. In the meantime, I will continue to have a great life with KM just as it is. It's such a great product. My memory isn't perfect, but I think my first version of KM was KM v2, and I bought it from the Apple App Store.

Peter has speculated on that possibility in the past, but as far as I know, he has no immediate plans to do that. He's just saying that anything's possible.

I think the main benefit (for me) will be that the KM Editor will be much speedier.

Maybe. Who knows what slows down the editor? Personally, I seriously doubt that a database would make that noticeable a difference to the speed of the editor.

But it's all speculation. Peter's the genius here, and I use that term intentionally.

1 Like

Rather than reply to that here, I may start another thread, because I can demonstrate my concerns, but that is really best addressed in another thread.

Experimenting with a bit of XQuery will quickly put you ahead of that curve – it lets you rewrite your XML to any format or datatype you like : -)

(Note that the NSXMLNode ObjectsForXQuery uses XQuery 1 (rather than 3), but that's more than enough, in practice)


Only Keyboard Maestro versions 4.4 (Mac App Store specific version of Keyboard Maestro more or less identical to version 4.3.2), and 5.x were ever in the Mac App Store. Mostly 2011.

Keyboard Maestro 2 was released in 2004.

Correct. Even if I used a database, it might be that the macros themselves were stored in XML.

The main advantage of a database would be that the editor did not have to write the entire XML file every time you make a change which would remove the restriction on the macro file size affecting the editor performance.

The editor also has performance issues related to long macros, which are cause by UI controls and would not likely gain anything from being in a database.

1 Like

Okay. I definitely stand corrected. My memory is fuzzy. You young people don't have to worry about memory loss.

1 Like