KM does not currently provide this.
But I agree, it would be a great enhancement!
@peternlewis, please consider this request.
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
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.
gvar_YourVariablename
local_YourVariablename
instance_YourVariablename
I don't have this macrotized at the moment, but it wouldn't be hard.
-Chris
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.
@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.
-Chris
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.
So:
Macro Name: Process Apple Mail Messages
Might become:
v_pamm_VarName
This allows me to easily find all variables related to a given macro in the variables panel of the KM prefs.
-Chris
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:
YourVariableName
in the Keyboard Maestro Editor.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.
-Chris
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.
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>
-Chris
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!
rub the lamp and