Create a new macro as part of a macro?

I do time tracking in Timery. I have a key-overloaded KM macro for each Timery Saved Timer. The issue is that I have to copy+edit / create a new macro manually for each timer I create.

I have a top level macro that creates a new new project across tools - in Obsidian, new folders in Outlook, new timers in Timery, new OS folders - all named consistently via a %variable%. I have most bits working except for the New Macro.

Is there an easy way to create a new macro in a macro, or is recording/tweaking my best bet?

Easy? Depends on your definition. :grinning_face_with_smiling_eyes: . I do it in my Palette Organizer.

Download the Palette Organizer and look for this group (the one the red arrow points at):


The actions put a new KM macro on the clipboard in the proper format for KM, then paste it into the current Group. So when the actions finish, the KM Editor will be editing the new macro.

This is how the new macro is defined in my code:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "">
<plist version="1.0">

This has a custom icon, so you can take out everything between the <data> and </data>. Or possibly delete the data tags also and use <data/>, similar to how "Actions" are defined above it with <array/>.

You need to define the variable Local_NewMacroName. It's possible you'll need to "escape" the macro name for XML, depending on what kind of characters are in it. I think the "Filter" action can do this.

Don't worry about the UIDs, KM will replace them with something new. Same with the dates. If for some reason you want to specify your own UID, just replace the final string with a variable containing your UID, which of course has to be unique or KM will just replace it with something else. There's a KM token for making UIDs.

If you want to add triggers, copy a macro as XML and examine how the triggers are defined. It's not easy to understand (at least not to me), but if you're motivated enough, you can figure it out.

Some tips:

  1. If nothing happens when you try and paste the new macro into KM, it probably means you messed up the format somehow - perhaps the macro name needs to be escaped for XML. Either that, or you didn't have the right part of the editor focused.

  2. Another possibility is you have a blank line at the start. KM doesn't like that, for some reason.

Let me know if you need help. Good luck.


Thanks @DanThomas! You weren't kidding when you questioned my "Easy" ask.

You do fantastic work - I'm still trying to decode the Switf Script block. My version is failing silently around there somewhere, but I can figure it out.

Thanks again for the excellent sample code!


If you can tell me exactly what you need, I can try and help. No promises, though.

Thanks for the offer, @DanThomas! I use an another app for time tracking, and I have a key-overload macro for each timer I need to start. Here's a snippet.


The new "New Project" macro I'm working on create a new project across all my tools: New folder+doc in Obsidian, new Folders in Outlook, new OS folders, new timer entries in Timery, and where I'm sticking is a new KM macro to activate the Timery timers. I've exported a working timer out as XML and changed the two occurrences of the name (the Macro name and the Timer name) with the right variable, and changed names to match in the SwiftScript block from your code. Best I tell, it's either failing silently in the SwiftScript block or just after. Any insight you can offer would be most welcome!


Well, it's not a Swift script, it's JavaScript for Automation, so that might be your first problem. :slight_smile: