UNTIL not stopping right away?

Even with 2 second pause and with only 1 event, it seems that it loops 1 more time after the event is deleted and the menu has "Edit>Delete" disabled.
I'm using the Notification "asd" just so I can see how many times it's looping after the event is deleted

Delete All Today's Events in Calendar.kmmacros (96 KB)

Keyboard Maestro Export

Here's what's happening. The first notification makes sense, but the second one doesn't, because since there's no event, the "Edit>Delete" is not there anymore so it should stop:
Screen Recording 2023-06-26 at 10.04.26 PM

@Zabobon is this normal? If so, how to fix it?

I can't run this Macro to test it out as I certainly don't want to inadvertantly delete all my Calendar events for today :rofl:

You can create a new calendar and disable all the others like I did:

Loops can be confusing to debug. And if they are used to delete things such as multiple Calendar events there is always the danger that they can run away with themselves, become an infinite loop and do a lot of damage in a short amount of time.

One thing I noticed for example in your Macro is that you simulate the Tab key to move to the next event you want to delete. If you are in Week or Month view, this will keep selecting future events beyond today and therefore deleting them.

If you want to delete the events for one day you could multiple select them (Command + click each event) and press delete. An awful lot safer IMO!

Not when you set the view to Today, which is how I use it, not the Week view.
In Today view, it stops when there's no more events, that's why it's going to the Search field when the last event is deleted

Yes, this is what I've been doing, but it's super annoying and time consuming, especially when you have recurring events and while you click an event you also move the mouse a little bit, Calendar is now assuming you are changing the event and asks if you want to make those changes. That's why I wanted a macro to do this.

I mean, it's working now, it's just that extra Tab that it weird, but I will try using the down arrow instead of Tab, which works the same way and hopefully in the end will not go to the Search field.

Yes, this seems to be a timing issue. Calendar's menus maybe don't update their state from "enabled" to "not enabled" quick enough to stop the loop. I had a play and came up with the below that seems to fix it. There are no fixed pauses in the Macro but you can see how long it takes for each menu state to change by the slowness of the process.

Delete All Today's Events in Calendar v2.00.kmmacros (9.0 KB)

Click to Show Image of Macro