Is there a way to create a macro that will press the "right arrow key" every 5 seconds on the Mac that I can turn on and off by pressing a hotkey. I'd like to use it for Flashcards.
The periodic trigger seems to work best, but I'm trying to have something I can turn on and off with a hotkey like Command+5:
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 14.5
Keyboard Maestro v11.0.3
It starts when you press Command-5, and ends when you either click the left mouse button or press the Control key. I included both methods just to show two ways to end the macro; you can use the pop-up menu in the Until action to see what other conditions you can set, so you can modify it to meet your needs.
EDIT: I just noticed you asked for five seconds, but your screenshots showed two seconds, so that's what's in my macro. Just change the delay to five if that's what you need.
Thanks Rob! The Macro works, but it doesn't turn off. I'm using a Macbook and clicking the left mouse key on the trackpad doesn't stop it. I tried your picture's Shift+6 arrow and tried a custom upward arrow key. Both don't stop it either. The Macro continues running once I enable it and doesn't stop even when I disable the Macro. I usually have to select "cancel all macros" from the dropdown in order to stop it from continuing.
I have a different approach. You don't need to use my approach if the current one is working for you.
The first step is to have a macro activate every 5 seconds (or two seconds, or whatever) like this. Make sure that when you do this, you place it into its own Macro Group. (I created a Macro Group called "Periodic".)
(You may eventually want to uncheck the Display Toggle feature above, but it's handy at first to see that it's working!) I forgot to mention, this second macro should not be placed in the same macro group as the first one.
I see what's wrong (sorry for the confusion): You have the conditions set to all of the following being true. You want any if you've got more than one trigger, as otherwise, you need to do both those things to stop the macro.
As well as having "all must be true" rather than "any", there's a problem with interrupts that work in this way.
The hot key trigger is an event -- KM is told when it happens and responds instantly.
In contrast, the "Until" action's conditions are states -- KM checks to see if they are true. So KM doesn't know that they have been pressed, it looks and finds that they are being pressed. And because the macro pauses for 2 seconds each time through the loop you are going to have to hold down the mouse button for an average of 1 second to stop the macro -- often more.
You can get round this by setting/checking a global variable which flags whether or not the macro is already running. You can have two macros, one that does the work and another that starts or stops the first. And I'm sure there are other ways.
Here's a single macro that works by checking all currently executing macros for one with the same macro name --- if there's none it'll start "pressing" the key for you, but if there is one that means the keys are already being pressed so it cancels the first instance then exits itself.
This will break if you have a completely different macro already running with exactly the same name, so watch for that.
I forgot to mention that bit, yikes! Thanks, @Nige_S. (I use macros like this a lot, as I like their simplicity and I'm aware of the conditional nature of the terminating events…but I often forget to mention it when sharing.)