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

applescript - cannot reference iTunes context menu

I cannot get any reference for the context menu and its child elements.


Accessibility Inspector reads


AXApplication

AXWindow:AXStandardWindow

AXMenu


but ASE always returns an invalid index. Also tried UI Browser to no avail.


Any ideas?

MacBook Air, OS X Mountain Lion (10.8.3)

Posted on Apr 13, 2013 8:39 AM

Reply
Question marked as Best reply

Posted on Apr 13, 2013 11:47 AM

iamsudo wrote:


I cannot get any reference for the context menu and its child elements.


Nor do I. However, with at least one track selected in the iTunes window, it is not too difficult, using GUI Scripting in conjunction with cliclick, to open the contextual menu and select a menu item. For example:


tell application "iTunes" to activate


tell application "System Events"

tell process "iTunes"

tell window "iTunes"

tell outline 1 of scroll area 1 of splitter group 1 of splitter group 1

tell (row 1 whose selected is true)

set {x, y} to position

end tell

end tell

end tell

end tell

end tell


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


tell application "System Events" to keystroke "Get Album Artwork" & return


Tested under OS X 10.8.3 with iTunes 11.0.2 and cliclick 2.2. (When using GUI Scripting, you must enable access for assistive devices in the Accessibility System Preference pane.)

18 replies

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.


User uploaded file

applescript - cannot reference iTunes context menu

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