Loop for X Seconds and/or Cancel Macro After X Seconds?

I have some macros I leave running and walk away from; if the computer falls asleep while the macro is running it prevents me from typing in my password to wake. :pensive: I’ve tried to figure out how to do this myself for a few days and can’t find a good way to do it. How do I set a group of actions to loop for X seconds instead of X repetitions, and/or how do I cancel a macro after X seconds?

Thank you

Hi

If I need to make sure my computer stays awake while running a macro I use this program
http://lightheadsw.com/caffeine/

It prevents the computer from going to sleep.

This is a great alternative. I will keep it in my back pocket, but I would still like to learn if there is a way to do the cancellation or exit loop by time. Thank you!

You could have a macro triggered by Sleep with action Cancel All Macros.

Otherwise, to loop for N seconds, do something like:

  • Set Variable Start to Calculation NOW()
  • While calculation NOW() - Start < 5*60
    • Do stuff

Keyboard Maestro Actions.kmactions (1.4 KB)

Thank you