Is there a way to make macros using code instead of the GUI drag and drop?

I'm new to this app and I just started making more complex macros with things like loops and conditions. I feel like it would be significantly easier to just write code instead of doing the drag and drop thing.

I've been incorporating scripting, but what I really want is to be able to write a whole macro using Maestro features.

I've messed around a bit with the import/export thing where you can get .kmmacros and .kmactions files that are html style, but it doesn't seem feasible to manually write those (and it's certainly not better than the GUI).

I know it probably doesn't, but I really want this to exist. Oh the things we could do.

There is no “text mode” for the macro editor, if that is what you mean, so no.

I understand what you mean, and ironically, ok, very ironically, I'm not really a fan of visual programming in general. But the editor brings a lot to the action building that would be difficult to do without a very impressive text editor system, things like dynamically populated menus of options, varying “syntax” of actions, displayed output of current results, etc.

You can use a scripting language of your choice, and control Keyboard Maestro Engine to perform tasks, including actions build via XML, or using the available options in the AppleScript dictionary.

But for making macros, you generally need to use the editor.

You can optimise your use of the editor with things like favorites, and with macros that let you insert customised actions or sets of configured actions, or the like. I've never felt the need to do that myself, but it's all possible.

One variant is to use a Copy as JSON macro in place of the built-in Keyboard Maestro Edit > Copy As > Copy As XML

In lieu of working with plist strings like:

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

you can then script with corresponding JS Arrays and Objects like:

      "IsDisclosed": false,
      "JustDisplay": false,
      "Text": "",
      "MacroActionType": "SetClipboardToText",
      "ActionUID": 11082764

and convert the script-generated custom JS objects to plist XML strings either at run-time, or in a final build stage, for use in this pattern:

Application("Keyboard Maestro Engine").doScript(plist);

An old thread here, perhaps ready now for some updating and simplification: