Loop Notification Macro (v11.0.4) - How to issue notifications for long wait times in loops

I decided to write a macro today to perform special processing for issuing notifications within loops. For example, let's say you have a typical piece of code like this: (this is a common type of loop that I use, but there are many different kinds of loops that this will work with.)

image

This is a very simple piece of code, but it could take seconds, minutes or hours to complete. And that's the issue. I like to be notified when something takes a long time to complete.

Wouldn't it be nice if there was a notification system, so that, for example, every 10 seconds the Mac beeps if the loop isn't finished, and every 60 seconds it says "Alert" if the loop hasn't finished, and every 5 minutes a text message is sent to your iCloud account if the loop hasn't finished. Those are three layers of notification which I personally would like to have available.

Well, now it's possible, with the following simple macro. Personally I like the values of 10 seconds, 60 seconds, and 5 minutes, so I hardcoded those values into this macro. But it wouldn't be too hard to change those values. And it wouldn't be too hard to make those durations completely programmable by the user. But for today I just wanted a simple solution to share with everyone. If people like this solution, but want more features, I'll consider adding new features.

Here's an example of how to use my new macro. Notice that you have to call it once to set it up, then call it a second time within a loop.

Notice that there's a call to my macro with the keyword "Setup" and then another call to my macro with the keyword "Detect". In both cases, the "Name" of the macro must be identical, and the "Name" is also used as a KM variable name where pertinent data is stored, so your "Name" must be a valid variable name that you are not using elsewhere. (I could certainly remove that requirement in a future version of this macro if it's desired.)

The above sample code would play a "Tink" sound every ten seconds, and make an "Alert" spoken message every minute, and send you a text message to your Messages app every 5 minutes - up until the conditions of the loop have been met.

I don't guarantee that this code has zero bugs. After all, I just wrote it.

Loop Notification Macro (v11.0.4)

Loop Notification.kmmacros (12 KB)