Connect to AirPlay via AppleScript

Short summary: Fixed the AppleScript to Connect to AirPlay

Some of you may have noticed that upgrading your macOS has broken the AppleScript for connecting to AirPlay featured in my previous post. Here is the fix: 

tell application "System Events"
	tell process "SystemUIServer"
		click (menu bar item 1 of menu bar 1 whose description contains "Displays")
		set displaymenu to menu 1 of result
		-- Tolerate numbers in brackets after the tv name --
		click ((menu item 1 where its name starts with "Apple TV") of displaymenu)
	end tell
end tell

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s