iTunes inspiration and FastScripts

Today, Daniel Jalkut (you know: MarsEdit, FastScripts; that Daniel Jalkut) posted a simple but very useful AppleScript on his blog. The script was inspired by a tweet from Todd Ditchendorf (you know: Fluid, Cruz; that Todd Ditchendorf) bemoaning the lack of a Go to Library keyboard shortcut in iTunes 9. Daniel wrote the script and, through the magic of FastScripts, gave it a keyboard shortcut that applies only in iTunes.

When I read the post, I realized that I had been wishing for something almost exactly like it. I almost never listen to my Music Library, per se. I typically listen to one of a few playlists—a smart list that excludes songs played in the past two weeks, a jazz/classical/ambient playlist for when I’m writing something difficult and don’t want to hear any singing, a set of recorded radio shows—so the Music Library is seldom the active view. But when I want to search for a song or an artist, it’s the entire Music Library I want to search through. I can’t tell you how many times I’ve started typing in the Search field only to discover that the search was being performed in the wrong playlist. Daniel’s script was the starting point for this Find in Music script, which sets the view to the Music Library, then puts the cursor in the Search field.

tell application "iTunes" to set view of (browser window 1) to playlist "Music"
tell application "System Events"
  tell process "iTunes"
    keystroke "f" using {command down, option down}
  end tell
end tell

I assigned it a keyboard shortcut of ⌘F (I’ve never liked that ⌘F is bound to the Full Screen command) and keep it in ~/Library/Scripts/Applications/iTunes, so FastScripts will run it only when I press ⌘F and iTunes is the active application.

I posted the script in the comments to Daniel’s post, but I figured I’d throw it in here, as well.