Want to highlight a helpful answer? Upvote!

Did someone help you, or did an answer or User Tip resolve your issue? Upvote by selecting the upvote arrow. Your feedback helps others! Learn more about when to upvote >

Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Keyboard airplay shortcut

I want to enable or disable the airplay at Mountain Lion on the keyboard via a shortcut. Is there a way to do this? Thank you

Posted on Jul 26, 2012 6:52 AM

Reply
12 replies

Aug 15, 2012 6:04 AM in response to Kralle70

Hi All,

I have been using my first iMac for about three days and loving it!


I was investigating this same question... with mixed success. I was able to create three shortcuts to make AirPlay work:


1. Shortcut to System Pref

2. Shortcut to Display

3. Shortcut to Airplay Device


I also created a fourth shortcut to turn AirPlay off in the display settings.


This works fairly well, but three shortcuts is a bit disappointing, does anyone have any tips to combine these into a single shortcut?

Feb 9, 2013 5:29 PM in response to Kralle70

If I understand your request correctly which I believe is that you want to enable/disable airplay mirroring with a quick keyboard shortcut. Then I suggest you do the following, bit techy but its easy to do.


  • Open Automator by going to Finder > Applications > Automator.App.
  • Create a new service.
  • First of all make sure your service takes no input by selecting "no input" on the top drop down menu.
  • Using the search bar on the left type in "Run AppleScript" and drag that to your window.
  • Type in the following code where it says (* insert code here *)


tell application "System Preferences"
      set current pane to pane "com.apple.preference.displays"
      activate
end tell

tell application "System Events"
      tell process "System Preferences"
             click pop up button 1 of window 1
             click menu item 2 of menu 1 of pop up button 1 of window 1
      end tell
end tell

tell application "System Preferences"
       delay 10
       quit
end tell


Hopefully you ended up with something like this:

User uploaded file

  • Save this apple script and name it whatever you want.
  • Open your System Preferences and navigate to your Keyboard > Keyboard Shortcuts Pane.
  • Select Services out of the list and scroll to the bottom. Your Service that you saved from automator should be on the bottom of the list.
  • Assign whatever keystroke you want and test it out!


By the way if you want to create another script to Disable airplay mirroring. It is also easy, just change the following line:


clickmenu item 2 of menu 1 of pop up button 1 of window 1


With this:


clickmenu item 1 of menu 1 of pop up button 1 of window 1

Nov 29, 2013 3:44 AM in response to Kralle70

I'm having issues with this on Mavericks where it requires whichever app is active at the time of hitting the keyboard shortcut to have been granted permission to control the computer.


This means each time I hit the keys in a new app, I need to go to System Preferences -> Security & Privacy -> Privacy -> Accessibility and then grant the app permission.


Does anyone know any solution to this, other than adding every single app to the list (which you can't do without it first trying and failing for that app, it seems).

Feb 12, 2014 3:18 PM in response to Kralle70

I have written an apple script which toggles between airplay speakers and regular speakers:


tell application "System Events"


tell process "SystemUIServer"

key down option

click menu bar item 4 of menu bar 1

key up option

set v to value of attribute "AXMenuItemMarkChar" of menu item 2 of menu 1 of menu bar item 4 of menu bar 1 as string


if (v is equal to "✓") then

click menu item 3 of menu 1 of menu bar item 4 of menu bar 1

else


click menu item 2 of menu 1 of menu bar item 4 of menu bar 1

end if


end tell


end tell


And as I wrote earlier:

Instead of giving it a keyboard shortcut in the Keyboard shortcut pane in System Preferences, using BetterTouchTool you can trigger a workflow (you find it under "Controlling Other Applications" in the "Trigger Predefined Action" drop down menu) with a keyboard shortcut (fn f12 for example). This avoids the problem Luke Noel-Storr described.

(Otherwise just handle the applescript following lPlacids instructions(exept the part involving the Preference Pane if you are using BetterTouchTool naturaly))

Keyboard airplay shortcut

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.