Skip to main content

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

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


Question Credit: Bilal Syed Hussain
Question Reference
Asked September 22, 2018
Posted Under: Apple
33 views
4 Answers

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

credit: Matthieu Riegler
Answered September 22, 2018

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.


credit: Community
Answered September 22, 2018

I found a way to do it on Mac OS X Mountain Lion 10.8. it uses cliclick from http://www.bluem.net/en/mac/cliclick/ to simulate a mouse click at the location of the clear button. The script assuming that cliclick is in /usr/local/bin

This works for me on a 15 inch macbook pro retina running at 1440x900@2x

To use the script either use the instructions by Matthieu Riegler for a global shortcut or use it from the command line

The code:

#!/usr/bin/env osascript
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
        set upNextButton to button 4 of scroll area 1 of window 1
        set pos to upNextButton's position

        --  160, 54  the number of pixels away the clear button is

        set clearX to (item 1 of pos) + 160
        set clearY to (item 2 of pos) + 54
        set cmd to "/usr/local/bin/cliclick -- " & {clearX, " ", clearY}
        do shell script cmd

    end tell
end tell

also a script for the mini player assumes that the up next list is closed

#!/usr/bin/env osascript
activate application "iTunes"
tell application "System Events"
    tell process "iTunes"
        set upNextButton to (first button of window "MiniPlayer" whose description is "show up next")
        click upNextButton
        delay 1

        set pos to upNextButton's position
        --  19, 48  the number of pixels away the clear button is 
        set clearX to (item 1 of pos) + 19
        set clearY to (item 2 of pos) + 45

        set cmd to "/usr/local/bin/cliclick -- " & {clearX, " ", clearY}
        do shell script cmd

        delay 0.1
        click upNextButton

    end tell
end tell

credit: Community
Answered September 22, 2018
Your Answer
D:\Adnan\Candoerz\CandoProject\vQA