Is it possible to trigger on an incoming phone call?

I would like to be able to perform some actions when I get a phone call. Specifically I want it to pause music since the notification blocks the use of the keyboard pause controls.

Does something happen on your Mac that lets you know there's an incoming phone call? If so, you could try to watch for that, but the macro would have to be running all the time in order to catch it. Perhaps there are other ways, but none come to my mind.

-rob.

I'm not sure whether you are answering your phone call on your phone or on your Mac. And is the music coming from the Apple Music app on your Mac, or from your HomePods, or from your iPhone using AirPlay?

What I'm trying to solve is that if I'm listening to music using the Apple Music app (playing through an audio interface) and a phone call comes in, the alert on my Mac prevents me from hitting the pause button on the keyboard. I end up answering the call on my iPhone and then fumbling to turn the music off. I thought that I might be able to use KM to pause the music automatically when a call comes in.

Do you have both of your devices (Mac, iPhone) logged into the same iCloud account?

Yes, that's why the calls show up on the Mac as well the phone.

Okay, well then something must be wrong because I answered a call on my Mac yesterday, just like that, and I think it automatically muted whatever audio was playing.

Now that I'm rereading your messages, I'm thinking that what you probably are asking is for the Mac to mute even if you answer the iPhone using your iPhone. That certainly wasn't clear from your original question.

Griffman's suggestion would certainly work. Did you try his suggestion?

I would like it to pause the music whether or not I answer. On the Mac there is an alert that pops up that allows me to answer it with FaceTime and it's that alert that prevents the keyboard pause button from functioning. Is there a way for that alert to trigger and action? I haven't been able to find that so far.

There aren't any notification-received triggers. If the keyboard is completely locked out when that alert is onscreen, then you can't use a keyboard-based macro trigger. Maybe a gesture trigger would work?

-rob.

Have you tried setting an Application Trigger to FaceTime on a macro that pauses your music app?

Does FaceTime launch if you don't answer the call? I thought it was just a notification on the screen unless you answered on the Mac.

-rob.

I presume you meant to say:

In the normal Keyboard Maestro sense of the word "trigger", the answer is no, and that's because Apple doesn't provide APIs for that feature. But in a larger sense, it's easy for a macro to "detect" things on the screen by polling for them. So the correct answer depends upon what you meant by "trigger." It's quite easy to write a macro that polls your Mac's screen looking (perhaps once per second) for a notification of an incoming call. I could probably write a two-action macro to solve your problem if you don't mind the macro "polling".

Apparently FaceTime doesn't need to be open. But there are some buttons displayed in the notification (as I recall) to decline or answer the call. See Make and Receive Calls in FaceTime on Mac.

Oh wow, never noticed, but you're right: FaceTime launches when an inbound call arrives. I thought it was just a notification, but it's not:

That window is in FaceTime. So you could use an application launch trigger to detect it:

image

Then maybe check to see if a button exists (Accept) in that window, and if so, do whatever it is you wanted to do? And if it doesn't, exit the macro as you would assume you launched FaceTime for your own use?

With all that said, however, I have a macro that pauses the Music app ... and its keyboard shortcut works fine when the inbound call notification is onscreen. Do you not use Music?

-rob.

2 Likes

That did the trick. I do use the Apple Music app and I was able to use Pause Current Track action. Thanks.

1 Like

Does anyone know how to do this exactly? The popup isn't part of the Facetime app but of the notifications interface, so I'm wondering what kind of method could be used to detect this.

At least in my case, this is a necessary part of the workflow since I want a trigger on incoming calls specifically, and not just when Facetime opens as an app.

P.S. hey @griffman love your blog. wow Panel Editor!?

I'm not sure how to do that—you might have to use image detection.

Thanks — and yea, that one surprised me as well, and had some pretty interesting Keyboard Maestro uses.

-rob.

For small images, OCR (when using Apple Text Recognition) may be faster than Image Detection. I think I wrote a post about this a few months ago where I measured the differences in speed. The FaceTime pop-up is very small and this could be a perfect situation for using OCR.

2 Likes

yep here it is: Speed Test for OCR (both for Apple and KM versions)

I'll try it out and report back. I got the image detection version working so I should be able to integrate this into it - or viceversa - and compare timings. Thanks!

No, that was a thread I started which compared Apple's OCR with Tesseract's (KM's original) OCR. I was alluding to a different thread where I was comparing Apple's OCR with KM's Find Image action. I think I concluded there that doing OCR on a small screen area was actually faster than using KM's Find Image action.