Set a keyboard shortcut to clear all tracks from the Up Next queue in iTunes

I am looking for a way to assign a keyboard shortcut to clear all the tracks from Up Next queue of iTunes. Does anyone know a way to do this?

Using Mac OS X Mountain Lion 10.8.4


Solution 1:

This following script will work on OSX < 10.7.

activate application "iTunes"
tell application "System Events"
    tell process "iTunes"
        click (first button of scroll area 1 of window "iTunes" whose description is "up next")
        delay 1
        click button "Clear" of UI element 1 of row 1 of table 1 of scroll area 1 of window 1
    end tell
end tell

Solution 2:

So here's a complete answer :


For iTunes 11 & OS X 10.6 (iTunes 11 requires at least 10.6.8) :

  • Create a new Automator service
  • Select Service Receives no input In iTunes
  • Add a Run AppleScript action
  • copy the code given by adayzdone. (You may need to adapt "up next" following the language of you system. For example on my French OS X it's "suivant")
  • Save the service.
  • Go to System Preferences > Keyboard > Keyboard Shortcuts
  • In Services, add a keyboard shortcut to your new service

For OS X 10.7 and above:

For the up next menu iTunes 11 uses an NSPopover which is available in OS X v10.7 and later. Therefore the hierarchy of UI Elements is different from the case above.

On iTunes 11.0.5, there is a bug where the button opening the Popover has no children. Therefore it is NOT possible to access the content of the popover to click on the clear button using Applescript.