Closing a MacOS system message

I have a KBM macro that opens and logs into a Java program. When I run the macro, I usually get this macOS system message. The login proceeds fine in spite of this, so I'd like to add, to the macro, a step that removes this message when it pops up, by clicking on "Ignore":


For testing purposes, I made this stand-alone macro just to close the message. It doesn't work... me this error message:

Even if I first click on the message to ensure it's the active window, like so, I get the same result:


Is "Ignore" not a "Button", or is the issue something else?

The following is the only approach I've gotten to work, but I'd rather not rely on Found Image, since I've previously found it doesn't function consistently. Though maybe it will work OK with something as distinctive as a caution triangle.

The reason Keyboard Maestro can't press the button is that macOS system messages don't have the same accessibility options as regular windows, so we have to find another way to do it.

This might work, although I'm not able to test with that specific crash notification:

activate application "UserNotificationCenter"
tell application "System Events"
tell process "UserNotificationCenter"

click button "Ignore"  of window 1

end tell
end tell

Thanks @noisneil. The first time I ran your code I didn't quite catch what happened. So I reopened the Java program to try again, but the warning message didn't appear. Further, I've since rebooted the computer a few times (in an attempt to reset things), yet I still no longer see the warning message when I open the program. It's simply gone for now.

So I'm afraid I can't test your code--it's as if running it that one time permanently disabled the warning message—which is curious, since it doesn't look like it would do that.

If the warning messages comes back at some point, I'll revist this and report back!

Would you happen to know if there is a Terminal command to check the status of System Event notifications?

1 Like

Not that I know of, but there's a lot I don't know of.