Cmd+S every "x" number of key presses

Hi,
I make music in Ableton Live which doesn't have a great auto save feature.
I've found ways in the past to automate a Cmd+S at a timed interval, but the problem is as a project gets bigger saving can cause a brief lag. So I'll be in the middle of working and suddenly the app freezes, which is not ideal.

What I'm thinking is if I could automate Cmd+S to go alongside another shortcut I already use, that would be like a roundabout autosave.
The best place I can think of is when I hit play (spacebar), because then if it freezes at least I'm not in the middle of doing something.
But, I don't want it to happen every time. I'm thinking maybe every 10 or 20.

So what I'm looking for is a macro that first and foremost allows the spacebar to passthrough as if the macro weren't running...
And then every "x" number of times it's pressed, Cmd+S is automatically run.

Ideally would only be active for Ableton Live, while the spacebar has regular functionality in every other app.

If a spacebar is particularly difficult, Cmd+F would be a good alternative to link the save command to.

I have zero prior experience with Keyboard Maestro but it seems like if any program can do it, it'd be this one.
Can anyone let me know if this is possible / how I'd go about it?

Thanks :slight_smile:

Ableton has a crash recovery system if i remember correctly, so I'm not sure how neccessary this is, but this is how you'd do it:

Create a macro group and in the Group setup, set it to "Available in these applications" and select Ableton Live. This will ensure any macros in the group only run in Ableton.

This should do what you are looking for and you can modify the last if condition to change the number of spacebar presses you want to wait until it saves.

Save Every 20 spacebar Presses.kmmacros (5.1 KB)

You’re a legend!! Thank you