Facetime automation for tv station

Im very new to applescript and I´m trying to create a script that would pop up a prompt for a phone number, then dial the entered phonenumber, i have found code for this that works ok, but here is the part im having a hard time with, I need a script that automatically closes, minimizes or moves facetime off the screen as soon as the call is ended. This is so the list of recent phone numbers accidentally can be broadcast on TV

Any help would be amazing, even just a point in the right direction

Thank you

You need to set up something that watches, observes or checks in on the status of the call. Then when it ends
Perform the necessary window closing / minimizing.

For example iTunes broadcasts a distributed notification every time it starts playing a new song.

I register to receive the notification. Also the notification contains user info dict about the new song and I can process when ever the song changes with the new info

The approach from “technomorph” would be the right one. For this, however, Facetime must send a corresponding distributed notification.

Open the macOS console app and search for “distnoted”. If you find a corresponding notification when hanging up, you can intercept it using the following template (for music) and process it accordingly:

use AppleScript version "2.4"
use scripting additions
use framework "Foundation"
use framework "AppKit"

property NSDistributedNotificationCenter : a reference to current application's NSDistributedNotificationCenter

on run
    NSDistributedNotificationCenter's defaultCenter()'s addObserver:me selector:"statusChanged:" |name|:"com.apple.Music.playerInfo" object:(missing value)
end run

on statusChanged:theNSNotification
    set userInfo to theNSNotification's userInfo()
    set theName to "Tilte:\t" & ((userInfo's valueForKey:("Name")) as text)
    set theArtist to "Artist:\t" & ((userInfo's valueForKey:("Artist")) as text)
    set theAlbum to "Album:\t" & ((userInfo's valueForKey:("Album")) as text)
    display notification theName with title theArtist subtitle theAlbum
end statusChanged:

(Must be run as an "Stay Open Applet)

This stand alone app is what I use and find really handy for checking out Distributed Notifications:


Thanks for the link. I compiled it and unfortunately it only shows the Workspace Notifications, since Apple makes it mandatory to give a name in the addObserver function for the Distributed Notifications.


Too bad. The only solution is the complicated search via “distnoted” in the console. :frowning: