Highlight Actions, Step-by-Step for Debugging

KM does not currently provide this.

But I agree, it would be a great enhancement!
@peternlewis, please consider this request.

Within the Keyboard Maestro architecture, this is not possible because the macro being executed is a copy of the macro at the time of execution, and not as it might be now, so there is no direct link between the running macro and the macro displayed in the editor.

@peternlewis, would it be possible to render the macro being debugged in a separate window, and highlight the next Action to be executed?

Not easily. Everything is possible. โ€œItโ€™s just code.โ€


I use an action like this for debug:

I use Dan's KMFAM to save this action and insert it to wherever I want the macro to stop and check display the variable value for me.

This is very useful for debugging.

A further thought: I think, it might be better if we are able to create a macro to

  1. get all the variables used in a macro that need debug.
  2. add these variables into the display text in a window in the debug action I created above to be displayed. Formatted as:

Varname1: %Varname1%
Varname2: %Varname2%
Varname3: %Varname3%

This will save some more time, as I usually have to edit the display text in window action to add the variables I want to display.
If I don't want to show certain variables, I can remove them from the list. Removing is easier than adding.

But (just did a quick search) looking at this post, this might not be easily accomplished as I initially thought.

Yes, we'd all love to be able to find all the variables used in a macro, but it would honestly take @peternlewis to make this feasible. There's too many different ways a variable can be referenced to do this ourselves, although I'd love for someone to prove me wrong.


If you use a naming convention for global variables you can copy the XML of a macro to the clipboard and find everything pretty easily.

Then sort and remove duplicates.


I don't have this macrotized at the moment, but it wouldn't be hard.


That's a good idea. I guess it's easy to get the local and instance variables, but, does anyone use the same prefix for all the global variables? I would be surprised to find even one user that has this consistent practice.

Keyboard Maestro actions are Turing-complete, so it is impossible, even in principle, to determine all the variables a general macro might reference, or even to determine if a general macro will run to completion or never finish.

1 Like


@JMichaelTX does.

I've started doing it, although I haven't settled on a permanent naming scheme yet.

With properly named variables you can find/replace to change from global to local/instance as needed and make debugging easier.

I've had to debug enough large macros now that I'm reconsidering my old practices.


I saw he used some DND global variables. I can get what the practice looks like now. The global variables does not require any prefix, we can thus freely design the prefix. I can see there are other benefits in doing this. We can use different sets of prefixes for different purposes.

I did not like this idea before because I don't like long variable names, especially when the text box is too short to display the entire variable name.

The DND prefix means Do-Not-Delete.

I typically use v_ or var_ for globals, and I'm experimenting with JM's practice of creating an unique ID from the name of the marcro.


Macro Name: Process Apple Mail Messages

Might become:


This allows me to easily find all variables related to a given macro in the variables panel of the KM prefs.



Is there a way to change the name of a variable in all macros that use the same variable?

Could it be done?

Unless you parse the entire Keyboard Maestro plist, you'd have to:

  • Find YourVariableName in the Keyboard Maestro Editor.
  • Find/Replace in each found macro.

I'm not willing to run the risk of fooling with the entire plist.

Whatever you do be very careful and make backups of things you're working on.


You can use the Search text box in the upper left to at least find where they're used. But you'd have to change them manually.

Thanks! I often left one or two places unnoticed when I had to change the variable names. When it happens, it's difficult to debug. But I did not use the Search function. I'll remember to use it next time.
Wish there's an AppleScript to tell KM to change the 'variable_name' in the current macro / all macros to 'another_variable_name'. It will save lots of time.

1 Like

It can be done if you want to put in the work.

I gave Peter an idea that might bear fruit in the future. <Fingers-Crossed>



I have often used QuickTime to record the screen while the debugging window is open.

Then I can go back and play frame by frame, and see whatโ€™s happening on screen AND in the debug window at the same time.


That's actually kind of a cool idea. Thanks!

1 Like

:slight_smile: rub the lamp and :slight_smile: