Toggle iTunes 11 MiniPlayer

November 29th, 2012

Today, Apple released iTunes 11, the anticipated update that has been due “sometime in November” since they announced it earlier this year. Judging from reactions on Twitter it’s having a mixed response: the new UI is, as expected, either refreshing or distressing depending on your particular attachment to the old look-and-feel, and the extent to which the new look speaks to you.

Folks who use FastScripts or another utility to script iTunes will be pleased to know that much of its scriptability is unchanged. I’m able to use my variety of scripts for playing and pausing, showing track information, etc., without any issue. But some subtle things have changed, including support for minimizing or maximizing the iTunes window. My friend Gabriel Roth framed the problem on Twitter:


I scratched my head about a proper workaround for this. Indeed, not only does the minimized property behave differently than documented in the scripting dictionary, the new “MiniPlayer” is an independent window from the main window. Although they seem to toggle between one another, you can actually select and make both visible from the “Window” menu in iTunes.

My first thought was to simply hide one window while making the other visible. This would be a fine solution except another bug in iTunes 11 apparently prevents the new MiniPlayer window from being exposed to the scripting object hierarchy.

So the compromise is to resort to UI scripting. By simulating the selection of iTunes’s own “Switch” menu item, we can rest assured that the toggle will happen as naturally as possible given the constraints we are facing.

Download the Toggle iTunes MiniPlayer script if you interested in hooking up a hotkey or otherwise automating display of the iTunes 11 MiniPlayer.

Update: Doug Adams (of Dougscripts.com fame) pointed out in the comments that my original solution was less ideal because scripters on non-English systems would need to open and modify the script to search for the correctly named item. I was able to update the script to search instead for the item by its keyboard shortcut alone. This should make the script more immediately useful to users of iTunes 11 regardless of the primary language they run their Mac with.

9 Responses to “Toggle iTunes 11 MiniPlayer”

  1. Eurobubba Says:

    UI scripting seems like a roundabout way of setting a hotkey….

  2. Daniel Jalkut Says:

    Eurobubba: it’s not “just a hotkey.” This is a general purpose script for achieving the toggling. Some people will use it to tie to a hotkey, others will find other creative uses for it. The main point here is iTunes lost scripting functionality and this replaces it with a workaround.

    To the point you’re getting at (clarified by your tweet), the specific example here of using e.g. FastScripts to assign a hotkey is more than just changing the hotkey for the menu item in iTunes. The hotkey via FastScripts would be accessible globally on the system regardless of whether iTunes is front-most. That’s often the use case for this kind of scrip to be able to toggle something about iTunes regardless of whether it’s focused or not.

  3. Eurobubba Says:

    Someday someone will develop a monster utility that grafts the menubars from every active application into one unholy, system-wide, hotkey-activated pop-up menu. And I will be the first to buy it. (Not from the App Store, presumably.)

  4. Doug Adams Says:

    Pity can’t use numbered menu item so non-English users don’t have to translate.

  5. Doug Adams Says:

    tell application “System Events”
    tell application “iTunes” to activate
    keystroke “m” using {command down, option down}
    end tell

  6. Daniel Jalkut Says:

    Doug: I considered that first but the problem there is you have to accept activating iTunes as part of the script execution. Another worry I have about that method is I have observed problems with UI scripting where, unless a delay is imposed after activation, the keyboard shortcut may not yet be “wired up” to the system by the time the keystroke event fires.

  7. Daniel Jalkut Says:

    Doug: there seem to be a variety of “mystery” accessibility attributes, besides the obvious ones like “title” etc. I see from Accessibility Inspector that the menu item exposes a kAXMenuItemCmdCharAttribute of “M” so it might be possible to interrogate the items for this attribute and choose the menu item to “click” based on that.

  8. Daniel Jalkut Says:

    Doug: OK – it got me thinking and I was able to modify the script to be completely language-independent. It only requires that the target item expose Cmd-Opt-M as the shortcut. In my brief tests I confirmed this worked in several languages so I am guessing iTunes never localizes the shortcut.

    Download the script again to check out the changes.

  9. William Bowles Says:

    Hmmm… a giant step backward if you ask me. If it ain’t broke, why fix it? Now my mini-player window no longer updates the titles of the music stream I listen to.

Comments are Closed.

Follow the Conversation

Stay up-to-date by subscribing to the Comments RSS Feed for this entry.