Looping a timed, simulated keystroke based on "frontmost application" status


I'm hoping that someone can provide me with an altered version of the KM macro in the attached image. I need the following to happen immediately after every instance of MS Word becoming the frontmost application:

Step 1. Wait 15 seconds and then simulate keystroke COMMAND-PERIOD.

Step 2. Immediately after simulating keystroke COMMAND-PERIOD, stop/kill the macro.

Step 3. Immediately restart the macro (i.e., the timer in Step 1) the second that MS Word once again becomes the frontmost application.

I've tried a ton of different combinations, but I just can't figure out how to kill and restart the process on demand, as outlined.

Thanks so very much for the help!

Rather than talking about the macro and how to adjust it, why don’t you define what you want to do what.

Presumably the only thing you want to do is type Command-. sometime. Define when that sometime is.

In the macro you show, the macro repeats every 25 seconds, but in your description, you say you want to stop after 15 seconds and kill the macro. So wouldn’t that mean you just want it to trigger on launch? And maybe launch and activation?

The only way to “kill” a periodic trigger would be to deactivate or disable it.