1

I'm trying to create a macro to manipulate some music (iTunes) tracks. One thing that I see is available without a menu/keyboard shortcut is the Show Album in Library command.

enter image description here

Does anyone know how to emulate this function (available only via mouse click) with AppleScript?

1

2 Answers 2

1

Hmm - not sure if this answers the spirit of the question. I'll leave it for now, trash it if it becomes clear it isn't relevant.

You can do it using the regular 'Application/Menu Title' shortcut structure - it doesn't have to be in a top menu for the system to be able to find it correctly.

System Preferences > Keyboard > Shortcuts > App Shortcuts.
Click the + button.
Select iTunes in the drop-menu
Type the exact menu name - "Show Album in Library"
Add a hot-key.
Click Add.

enter image description here

It's already showing in the window because I'd already added it to test, before deciding to do the snapshot

2
  • This is new, to have right-click menu items in shortcut's menu title ! I uselessly installed cliclick that day: apple.stackexchange.com/a/380032/313842
    – anki
    Commented Feb 1, 2020 at 18:57
  • With Music (1.2.5.7, Monterey), a 'Show Album in Library' shortcut won't work to navigate to the album of the currently playing song, as that appears in a context menu only. If you highlight a song in the Songs list, it will bring you to that album, as that is a main menu item. Commented Dec 7, 2022 at 0:36
0

The simple solution is to tell application "Music" to reveal current track. The problem with that is that it only works if the track was played from the library, rather than from a playlist. So, instead:

tell application "Music"
    set musiclist to first playlist whose special kind is Music
    set track_id to persistent ID of current track
    activate
    reveal (first track of musiclist whose persistent ID is track_id)
end tell

The first playlist whose special kind is Music is the built-in playlist that contains all the music in the library. We use whose to search that list for the current track's persistent ID and reveal that track.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .