Repeatedly running a macro for an active app with multiple workspaces

I am using DJ software called Traktor which is notorious for occasionally crashing but doesn't have autosave built in. I want to fake it by having Keyboard Maestro automagically simulate the keystroke Cmd+S every 5 minutes, but only while Traktor remains in focus.

I created a macro that is triggered by Traktor activation with an Until loop that continues until Traktor is not in front. The problem is that if I leave Traktor running and switch to another workspace, the macro keeps running and get captured by whatever app happens to have focus in the current workspace. How can I fix this?

What I really want is "while Traktor is running, every 5 minutes send Cmd+S to Traktor" and if Traktor is not the current/active app, don't do anything. The loop can be re-activated once Traktor regains focus.

Thoughts/suggestions on how to accomplish this?

Try using a “While” loop rather than an “Until” loop. This is available from the Engroup option.

The condition would be to keep the loop going “while” Traktor is frontmost.

The difference is that the until loop will always execute all actions before stopping (including the pause and save) and the while loop quits instantly no matter at what point in the loop it is.

You could also create a macro group that is only active in that application, and have a “save” macro that executes every 5 minutes, upon idle, etc.

You could also perhaps use the Select or Show a Menu Item action to just send the save command directly to Traktor no matter what app you’re in and have that trigger every 5 minutes, periodically etc.

1 Like

Hi, @oonate. Here's another approach you could take. I don't have Traktor, so I created a macro group and macro for CotEditor, a free text editor. Obviously you'd want to modify both for Traktor.

CotEditor Group ( expand / collapse )

Download: AutoSave CotEditor Doc.kmmacros (11 KB)


  • Macros are always disabled when imported into the Keyboard Maestro Editor.
    • The user must ensure the macro is enabled.
    • The user must also ensure the macro's parent macro-group is enabled.

System Information
  • macOS 13.4.1 (22F770820d)
  • Keyboard Maestro v10.2

1 Like