iTunes 11.0.3 provides AppleScript support for controlling AirPlay devices. Below is a basic script that illustrates how AirPlay devices can be selected and applied using some of the new iTunes AppleScript classes and properties:
tell application "iTunes"
set apDevices to (get every AirPlay device whose available is true)
if apDevices is {} then display dialog "No Airplay devices available." buttons {"Cancel"}
set apNames to (get name of every AirPlay device whose available is true)
set selAirplayDevices to (get name of every AirPlay device whose selected is true)
set chosenNames to choose from list apNames default items selAirplayDevices with prompt "Select Airplay device:" with multiple selections allowed
if chosenNames is false then return
set apChoices to {}
repeat with i from 1 to length of apNames
if item i of apNames is in chosenNames then set end of apChoices to item i of apDevices
end repeat
set current AirPlay devices to apChoices
end tell
tell application "iTunes"
# possible values for kind are computer/AirPort Express/Apple TV/AirPlay device/unknown
set newAirplayDevice to (get some AirPlay device whose kind is computer)
set current AirPlay devices to {newAirplayDevice}
end tell
Mac OS X Hints
http://hints.macworld.com/article.php?story=20130520061835490