Apple Event: May 7th at 7 am PT

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

Cannot access context menu item in iTunes using AppleScript

I have written an AppleScript to import tracks in itunes and write iD3 information for that track. The problem is that I need to add album artwork as well and since it does not exist any api for that in the Dictionary I have to select the song in iTunes right-click and select "Get Album Artwork" in the context menu (I cannot use Advanced - Get Album Artwork since it gets art for all my many thousand tracks). Although I use the Accessibility Inspector I cannot access the menu item "Get Album Artwork". The error message given is 'Can't get menu 1 of window "iTunes" of process "iTunes"'.


This is my best shot. Before I execute the script I open iTunes and select a track manually.

tell application "iTunes" to activate


tell application "System Events"

tell process "iTunes"

tell window "iTunes"

tell menu 1

tell menu item "Get Album Artwork"

perform action "AXPress"

end tell

end tell

end tell

end tell

end tell


This is the information I got from Accessibility Inspector.

<AXApplication: “iTunes”>

<AXWindow: “iTunes”>

<AXMenu>

<AXMenuItem: “Get Album Artwork”>


Attributes:

AXRole: “AXMenuItem”

AXRoleDescription: “menu item”

AXParent: “<AXMenu>”

AXEnabled: “true”

AXPosition: “x=427 y=518”

AXSize: “w=179 h=18”

AXTitle: “Get Album Artwork”

AXHelp: “(null)”

AXSelected (W): “true”

AXMenuItemCmdChar: “(null)”

AXMenuItemCmdVirtualKey: “(null)”

AXMenuItemCmdGlyph: “(null)”

AXMenuItemCmdModifiers: “0”

AXMenuItemMarkChar: “

AXMenuItemPrimaryUIElement: “(null)”


Actions:

AXCancel - cancel

AXPress - press

iTunes 10.4-OTHER, Mac OS X (10.5.8)

Posted on Aug 22, 2011 10:36 AM

Reply
17 replies

Cannot access context menu item in iTunes using AppleScript

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