Questions about Big Sur and [KMFAM] Favorite Actions and Macros

I've just re-installed Dan's [KMFAM] Favorite Actions and Macros with plans to use it again going forward and notice quite a few variables with a kmfam prefix. I also continue to use JMichaelTX's [KM] [DELETE All Variables Except Those on Keep List] and wonder if all the other kmfam variables not prefixed with DND__ are safe to delete and exclude from the DND__KM_Vars_To_Keep list?

Thanks to you both for great KM tools & assistance!

@peternlewis - Here's an action at the end of the macro "[KMFAM] Select":

tell application "Keyboard Maestro Engine"
	set value of variables whose name starts with "kmfam" to "%Delete%"
end tell

It doesn't appear to work. For some reason, the KM Engine isn't able to find variables that start with "kmfam", or at least not all of them. I've verified this in Script Debugger also.

I'm hoping you use KMFAM and can figure out if I've done something wrong somehow, or if this is a bug in the engine. If not, do you have any other ideas?

Thanks.

Dan

What variables do you have and what happens?

I don't have kmfam variables, but I had a bunch of variables that started with “Web” and ran the equivalent script from AppleScript:

tell application "Keyboard Maestro Engine"
	set value of variables whose name starts with "Web" to "%Delete%"
end tell

And it deleted all of them.

So I'll need more information about it to figure out what might be going on.

Dan & Peter,

I pasted the delete actions from "[KMFAM] Select" into a macro for use after invoking [KMFAM]. The first screenshot shows the variables created from the use of the [KMFAM] utility.

This second screenshot shows what remained after attempting to delete all the kmfam variables.

So, it appears that some are deleted, but not the five variables shown.

Dan,

Additionally, its still not clear what variable names to list in JMichaelTX's macro "Keyboard Maestro Delete Variables Except Those On Keep List". I've listed the two below with and without the DND__ prefix, but his macro deletes them. So, on the next run of your utility, I have to again report/declare the KMFAM Resources folder path.

DND__kmfamResourcesFolderPath
DND__kmfamWindowPosition

Lastly, the following variable is not even deleted by the JMichaelTX macro:

kmfamActionName

Any suggestions?

@DanThomas and @peternlewis:

I just ran a test using SD7, and it appears that AppleScript can NOT see (have access to) KM variables that are empty (no value shows in KM Prefs).

tell application "Keyboard Maestro Engine"
  set value of variables whose name starts with "kmfam" to "%Delete%"
  set kmVarList to name of variables whose name starts with "kmfam"
end tell

AppleScript found and deleted these variables which also showed in the KM Prefs:

kmfamActionName
kmfamActionType
kmfamcResult
kmfamFavoriteActionDialogIsRunning
kmfamMacroNameFocused
kmfamOptions
kmfamPickListSize
kmfamPreferencesFolderName
kmfamPreferencesFolderPath
kmfamRequest
kmfamSelectData
kmfamUpdatedUsageData
kmfamWindowHeightWithoutPickList

However AppleScript did NOT see nor delete these KM Variables that also showed in KM Prefs:

kmfam__Existing Action
kmfamErrorMessage

The first group all had some value.
The latter group did not have a value.

BTW, currently KM Editor is in non-edit mode, and the current macro has nothing to do with KMFAM.

1 Like

"DND" means "Do Not Delete". You can delete anything else. But follow along in this thread, because we're zeroing in on the problem.

@peternlewis

Yeah - what he said. :stuck_out_tongue:

Yes, variables without values do not exist.

However variables that are used in any macro in Keyboard Maestro will still be displayed in the Preferences or in the popup menus for selecting variables or the like.

But they don't exist as far as AppleScript is concerned.

Just to add clarity to how Variables work with Keyboard Maestro:

  • You delete a variable by setting it to the empty string. At that point it is removed from the variables database.
  • Keyboard Maestro will show you variables that have values as well as variables you use in any macro in the Variables preference pane, and in Variables popup menus and Insert Variable by Name or Insert Variables menu.
  • You can actively hide a variable from those displayed locations by setting its value to the special token %Delete%. However this does not delete the variable from the database, in fact the opposite, it ensures it is in the database with this special value.

For variables you want to delete at the end of the macro, perhaps you should move to using Local or Instance variables?

Peter, I hope you can appreciate contradiction in terms that this presents. :wink:

At this point, I see no value in the %Delete% token.

Yep, this is what I now do. For all new Macros I've written since KM 8.0.2, I've used Local/Instance variables, unless I want the variable to persist across executions and macros. Then, I prefix these with "DND_".

The major downside of this is that there is no easy way to inspect Local/Instance variables while debugging a macro. It would sure be nice if the KM Debugger would show Loca/Instance variables, like most debuggers I have ever used.

1 Like

Yes, and no. It does not delete the variable, it deletes the variable from the Popup menus and Preferences and such.

The purpose of the token is to hide variables from the Popup menu that selects Variables.

Yes, it would, and yes it is a pain, but currently that is unlikely any time soon I'm afraid.

The solutions are to use tools like Log and Display Text and such to display the variables as necessary. It is not ideal, but it is what it is. If it is any consultation (probably not) it is how I generally debug Keyboard Maestro since the debugger generally does not show me variables there either.

A post was split to a new topic: Request: Provide Dynamic Display of Macro Variables in Debugger