Skip navigation

applescript - cannot reference iTunes context menu

1297 Views 18 Replies Latest reply: May 11, 2013 10:55 AM by iamsudo RSS
  • Pierre L. Level 4 Level 4 (3,860 points)
    Currently Being Moderated
    May 10, 2013 8:12 AM (in response to iamsudo)

    iamsudo wrote:

     

    Just one last question, is there any way to access the "Add To…" context menu (the one with the > in a circle) with GUI scripting?

     

    Screenshot 1.png

     

    In the situation depicted by the above screenshot, you can either control click on the song title "Chiquitita" or do a normal click on the button to the right of the title.

     

     

    Screenshot 2.png  Screenshot 3.png

     

     

    It is rather easy to access the first menu above with GUI scripting:

     

    tell application "iTunes" to activate

     

    tell application "System Events"

        tell process "iTunes"

            tell window "iTunes"

                set {x, y} to position

                set {h, v} to size

                set {x, y} to {x + h div 2, y + 20}

            end tell

        end tell

    end tell

     

    do shell script "/usr/local/bin/cliclick kd:ctrl c:" & x & "," & y & " ku:ctrl"

     

     

    On the other hand, the only way I could think of to access the second menu above is to first switch to the MiniPlayer window. The following script seems to work flawlessly on my MacBook Pro under OS X 10.8.3.

     

    tell application "iTunes" to activate

     

    tell application "System Events"

        keystroke "m" using {option down, command down} -- switch to MiniPlayer

        tell process "iTunes"

            repeat until exists window "MiniPlayer"

            end repeat

            tell window "MiniPlayer"

                set {x, y} to position

                set {h, v} to size

                set size to {400, h}

                set {x, y} to {x + 77, y + v div 2}

            end tell

        end tell

    end tell

     

    do shell script "/usr/local/bin/cliclick c:" & x & "," & y

     

     

    Hope it can help.

     

    Message was edited by: Pierre L.

  • Pierre L. Level 4 Level 4 (3,860 points)
    Currently Being Moderated
    May 11, 2013 8:34 AM (in response to iamsudo)

    I thought I could get the size of the actual text of a song — not the text field — to click right next to it, but I still couldn't figure it out.

     

    Good idea! I tried it, but was unable to find a way to get that size. Maybe you could try something else: temporarily reduce the text field to its minimum width and then click right next to the end of it. It should work for most songs, except those whose title is very short.

     

    Capture d’écran 2013-05-11 à 11.17.50 AM.png

1 2 Previous Next

Actions

More Like This

  • Retrieving data ...

Bookmarked By (0)

Legend

  • This solved my question - 10 points
  • This helped me - 5 points
This site contains user submitted content, comments and opinions and is for informational purposes only. Apple disclaims any and all liability for the acts, omissions and conduct of any third parties in connection with or related to your use of the site. All postings and use of the content on this site are subject to the Apple Support Communities Terms of Use.