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)