dougscripts.com

January 10 2011 - 12:42 pm

Skip Back or Ahead Custom Mods

Recently, I was watching a DVR of a football game I had made with EyeTV. In general, I prefer to skip the parts that aren't showing football players playing football. So, while watching the game on iTunes I used the script Skip Back or Ahead to jump ahead 120 seconds when necessary.

The thing about that script is that I didn't exactly streamline the workflow. Here are the steps required to skip ahead 120 seconds:

  1. Click the iTunes Scripts menu, scroll, and click the script's name to launch the script
  2. Enter the number of seconds in the dialog that appears--in this case the three digits "1-2-0"
  3. Click the "Ahead" button to dismiss the dialog

...and then the playing iTunes track, my football game, advances two minutes. But although it looks like just three quick steps it seems to take about a half an hour to perform. OK, not a half an hour. But it does seem kinda clunky to have to do a lot of mousing and key pressing just to perform a simple task like skipping ahead.

Here's what you can do to streamline the script at your house.

First, give the script a keyboard shortcut. I used Option-Command-S. That eliminates the preliminary mouse business with the Scripts menu.

Second, there's no default button set in the script. You have to use your mouse to select "Back" or "Ahead" (you can, however, always use the esc key to "Cancel"). Since I'm pretty sure I'll want to skip "Ahead" about ninety percent of the time—In more rare situations I can always explicitly choose "Back" by using a mouse click—I'll set the "Ahead" button as the default button in the dialog so that I can use the return key to dismiss the dialog while choosing "ahead". Here's how to do that.

Open the script with AppleScript Editor (located in /Applications/Utilities/) and find the section that looks like this:

display dialog addenda & "Skip Back or Ahead this many seconds:" default answer ¬
	"" buttons {"Cancel", "Back", "Ahead"} with title my_title

Add this code, default button 3, inline right after the bracketed list of button names. This sets the third button in the list, "Ahead", as the default button. Save. When run, the "Ahead" button will be highlighted in the dialog and will respond to a return key press.

Now the steps to skip ahead go a bit more briskly:

  1. Press Option-Command-S to launch the script
  2. Enter the number of seconds in the dialog that appears--the three digits "1-2-0"
  3. Press return

That just seems so much easier and faster.

But wait! What if I always will ever only want to skip ahead 120 seconds? Then only this part of the script with the 120 hard-coded is needed:

tell application "iTunes"
	if player state is stopped then return
	try
		set player position to (get player position) + 120
	end try
end tell


CAVEAT: Don't try to run a script via shortcut if you are watching video in iTunes in full screen. I've had inconsistent results, including freezes and crashes.

Site contents © 2001 - 2024 (that's right: 2001) Doug Adams and weblished by Doug Adams. Contact support AT dougscripts DOT com. About.
All rights reserved. Privacy.
AppleScript, iTunes, iPod, iPad, and iPhone are registered trademarks of Apple Inc. This site has no direct affiliation with Apple, Inc.
The one who says "it cannot be done" should not be interrupting the one who is doing it.