Save and recall a selection of variables

Hey Kevin,

You should provide a couple of examples of what you’re trying to store.

There are all kinds of ways to save a retrieve data – here’s one:

Passing complex data between KM actions using JSON

You can find/replace in a simple structured text file.

You can save an AppleScript object.

You can use the defaults system.

You can create your own SQLite database and then save and retrieve data to and from it.

A very simple AppleScript example.

Change “Ren_” in the example to something common in your Keyboard Maestro variables.

Run the example in the Script Editor.app.

tell application "Keyboard Maestro Engine"
  tell (variables whose name starts with "Ren_")
    set {varNameList, varDataList} to {name, value}
  end tell
end tell

Then examine the Result panel in the Script Editor.

You’ll see something resembling this:

{{“Ren__Find”, “Ren__Repl”}, {“PopChar”, “PopChar X”}}

That’s two lists – one is the variable name – one is the variable content.

Something like this can be stored and retrieved quite easily.

-Chris

1 Like