macosapplescriptitunes-app

Selecting a item from a list of filenames in Applescript


My app needs to select a given filename from a list of filenames presented by iTunes' "Import Playlist" dialog. According to Accessibility Inspector the majority of the list's parent have no description and one item is described as an "NSBox". MY SPECIFIC PROBLEM IS THAT TRYING TO REFER TO THE "[NSBox]" AS "group 1" FAILS WITH THE RUNTIME ERROR ESSENTIALLY SAYING THE NUMBER IS TOO LARGE?!

This is a near identical situation to my earlier question How do I refer to an object in a window whose Accessibility Inspector description is "<empty description> (group) [NSBox]" in Applescript? for which the only answer presented an alternate method of accomplishing my specific task at the time.

The list item marked with a * rather than a - is the actual item I had selected in Accessibility Inspector. The full hierarchy of the specific item I need to select in one example case is:

- iTunes (application) [ITNSApplication]
- import (dialog) [NSOpenPanel]
- <empty description> (group) [NSBox]
- <empty description> (split group) [Fl_TSplitView]
- <empty description> (split group) [Fl_TSplitView]
- <empty description> (scroll area) [Fl_TListScrollView]
- (list view) [Fl_TListView]
- <empty description> (outline row) [NSOutlineRow]
* Library.xml (cell) [NSTableViewCellMockElement]
    - Library.xml (text field) [Fl_TListNameFieldCell]
    - <empty description> (image) [NSImageCell)

Solution

  • [NSBox]'s are called "outline"s by Applescript so the specific solution would be tell app "System Events" to tell process "iTunes" to select row [number or variable here] of list view 1 of scroll area 1 of split group 1 of split group 1 of group 1 of window "import" [or "its front window" and yes, that is the correct spelling of "its"].