Transmit each macOS Notification to a Portable iCloud Device Macro (v11.0.3)

I have seen many requests for macOS "Notifications" to be detected, so that an action can take place based on the text of the notification. As Peter says in the following thread, there is no way to do this using official Apple APIs. However I live by the adage that anything you can do with your eyes, ears and fingers can be replicated with KM macros and actions. So I've just created a macro that can, more or less, solve this problem. (But it may require a little tailoring for each situation.)

My macro has a few mandatory requirements:

  • Your Mac must not be set to sleep or even lock its screen;

  • Your Mac must have no icons (eg, files) in the upper right corner of your screen;

  • You will need to insert your own cell number or iCloud email address into the Send action inside this macro.

  • At the start and end of my macro is a Semaphore Lock and Pause action. This is needed to prevent duplicate alerts for the same Notifications. However you may be able to shorten the Pause a little bit.

  • This macro has a periodic trigger set to 3 seconds. The value of 3 seems optimal for most situations, but you can trying modifying it a little. Values of 1 to 5 may be viable.

  • You must validate that the OCR action near the top of the screen is reading the text area of the Notifications window. While I'm using the default resolution on an iMac, your screen may have different resolutions and therefore you will likely have to change these values. I have added a Highlight action to help you validate the area which is being read by the OCR action. Once you are sure that it is reading the correct area, you may (or may not) want to disable the Highlight action.

My macro has a few minor conditions that may be helpful for good operation:

  • Your Mac's screen background should probably be a solid colour;

  • Apple has a priority system for messages that may prevent text messages or iMessages from going to your portable device if you are sitting in front of your Mac while being logged in to your Mac (which might mean different behaviour based on where you are);

  • Depending on your personal preferences, you may want to delete the action that replaces carriage returns with dashes.

  • My macro has a condition that validates the message is at least 5+ characters in length. This is intended to remove some false detection alerts, but you may be able to remove it, since it usually doesn't do anything.

Bugs:

  • My app isn't designed to handle cases where multiple alerts come at the same time. That could be an enhancement for the next version. You might get incorrect results if multiple macOS Notification come in at (almost) the same time.

I've been testing it for a few days and while it can work when you are using your computer, it's really designed for situations when you are away from your computer.

Transmit each macOS Notification to a Portable iCloud Device Macro (v11.0.3)

Transmit each macOS Notification to a Portable iCloud Device.kmmacros (8.2 KB)

1 Like

Hi @Airy!

This is cool, and thanks for sharing — but this is also almost strange: About a couple of days ago, I made a macro with its core functionality overlapping this one.

But as you point out, there has been interest in this forum for such functionality, so I guess the idea was incepted™ in us in some similar way. Anyways, I have also been really interested in having notification presence/content as a trigger or condition, so I spent a couple of days on this earlier this week.

My take consists of 1) an Apple Script "applet" that triggers the macro based on screen presence of Notification Center Dialog Window; and 2) a macro that finds the boundaries of the (topmost) notification, OCRs its content, and logs it with timecode as a single line in a global variable.

I had anyway planned on sharing it, and thought about posting it here in this thread, but I chose to post it as a separate Tips & Tricks post instead of posting it here. But have a look, there are some really cool ideas there — in my view anyways, but I believe there are interesting elements in there for you as well

I will look, but I will need to get in the mood for reading AppleScript. I'm sure it's very cool. Maybe the two beasts can merge and have an even better offspring.

1 Like