Is My Keyboard Maestro Setup Corrupt?

I am a huge fan of Keyboard Maestro and use it every day.

Two days ago a weird thing happened: apparently due to some kind of syncing error event, I had duplicates of most or all of my scripts. Trying to run a script would result in KM asking me which script to run, and some scripts ran twice at the same time.

I went through and deleted the duplicate macros, but now I have a new problem: commands that should work from inside an Applescript now generate an error, shown below. It seems that I cannot execute these commands from inside an AppleScript that KM is running.

tell application "Keyboard Maestro Engine" to do script "run some script"

tell application "Keyboard Maestro Engine" to setvariable "saveSomeVariable" to 1 as integer

Does anyone have any suggestions about how to get this functionality back? I frankly use Applescript to save variables and run KM scripts all the time. Is there a way to export a "clean" version of all macros and re-import them, if I'm looking at a corrupt file?

Screenshot 2023-03-12 at 1.29.02

OK, part II to my problem. Since my KM set up was completely broken, I took the extreme step of exporting all of my macros, several times, using Export Macros, Export Macro Library, and Export Macros to Folder. I thought that I could add back my Macros one by one, verifying that they were working.

Well. I did this, but to my shock and horror maybe 40% of the macros did not get exported, and appear to be lost. I thought, no problem, I'll load my shared KM library from a Time Machine backup on another computer, so I can see which macros are missing and fix things. BUT.... loading the kmsync file doesn't seem to restore my macros, and I can't see how to import macros from a recovered folder in Application Support inside Library.

Basically, I desperately need to restore my Macros from a Time Machine backup so I can rebuild my workflow scripts, but I can't see how to do this. Please help!

The Time Machine backup should have everything you need to restore your Library (but you would not use the kmsync file from the Time Machine Backup - you would do this).

But there is a simple option that does make use of the kmsync file if you have been syncing via Dropbox (and I have had to do this a few times so I know it works). Do you use Dropbox for syncing? If the answer is yes, you will be able to restore the kmsync file to a previous version directly in Dropbox.

  1. On your main Mac set Keyboard Maestro to sync its Macros and point it at the same kmsync file in Dropbox that you have always used.
  2. Initially it is just going to sync to the current state with Macros missing etc
  3. Quit Keyboard Maestro
  4. In Finder go to the Dropbox kmsync file, right-click and choose "Version History"
  5. This will take you to Dropbox on the Web where you can restore the kmsync file to an earlier date.
  6. Restart Keyboard Maestro and your Macros should be back.

Once you have your Library back, this is the option to use:

Click to Show Image of Menu

If by “script” you mean “macro”, this cannot happen because of a syncing error. Syncing works by syncing the entire macro file, so there is no opportunity to duplicate macros.

Generally the only way you can duplicate macros would be to duplicate them in the editor (or via AppleScript to the editor), or by importing copies of the macros.

In the Keyboard Maestro File menu, there is an option to revert macros to previous dates.

A Macro Library is never what you want to save or restore macros. Mostly the Macro Library exists only to provide the original macros, it was never useful at other purposes.

Exporting macros will only export the selected macros.

Generally you should not use the .kmsync file to restore macros. The files in the Keyboard Maestro preference folder can be transfered/restored as described in the manual at How do I backup / migrate / transfer my installation to another Mac.

If you really want to restore from a kmsync file, ensure that the kmsync file is at the version you want to install it from, and turn on Macro Syncing on the Mac you want to replace the entire macros for, and select the kmsync file for Opening. Read the warning carefully. After sync, you can turn syncing straight back off again, so the kmsync file can be anywhere.

1 Like

THANK YOU for your help. I was able to get functionality restored by replacing the whole KM folder in Application Support. The weird bug that was giving errors when I did certain KM commands seems to be gone.


Thanks for the reply. I got functionality restored by restoring the whole folder in Application Support and it is working again.

1 Like