Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Create an iTunes shortcut with DragThing Apps
All I wanted was a global hot key to go to the next/previous track in iTunes. Sometimes iTunes goes to a song you don't want, and you want to skip to another without using the Dock or switching to iTunes from whatever you're doing. I wrote two tiny AppleScripts to control iTunes, and then looked for ways to assign them to keys. No luck with function keys as in OS 9 (what ever happened to the F-key section from the keyboard control panel?), so Dragthing came to the rescue.

I didn't want anything to jump into the foreground, so I set up a new dock (called 'hotkey scripts') and set it to 'allow AppleScripts to run in background' in the Miscellaneous preferences tab. I then added my scripts to the new dock, and used the 'item options' from the contexual menu to set a hotkey for each. I set it so that Apple+left and right arrows are previous and next track, but any key combo would do it, presumably as long as it's not used elsewhere. The Applescripts, for anyone interested, are simple:
tell application "iTunes"
next track
end tell
Replace next with previous for the other script, obviously.

Now I can control iTunes from anywhere :-)
  • Currently 1.00 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (1 vote cast)

Create an iTunes shortcut with DragThing | 10 comments | Create New Account
Click here to return to the 'Create an iTunes shortcut with DragThing' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Cool idea.
Authored by: james_sorenson on Apr 16, '02 11:55:18AM

Was there life before DragThing? I think I will just use this to assign my F9 to F12 keys with Prev, Next, Play, Pause. Thanks for the tip!

By the way, there is a new update of DragTHing to version 4.3.

[ Reply to This | # ]
do the same thing with quickeys & more scripts
Authored by: loren_ryter on Apr 16, '02 12:21:43PM

you can do the same thing with quickeys, and maybe other similar applications that allow you to assign applescripts to keys.

i have a whole bunch of itunes keys configured. usually with an arrow key and a modifier.

for instance

* previous track

tell application "itunes"
previous track
end tell

* next track

tell application "itunes"
next track
end tell

* volume up

tell application "itunes"
set sound volume to sound volume + 10
end tell

* volume down

tell application "itunes"
set sound volume to sound volume - 10
end tell

* toggle play/pause (only IT 2.0.4)

tell application "itunes"
end tell

* pick a playlist & play (best run from a file):

--pick a playlist;
--no options for quick keys

tell application "iTunes"
set the_playlists to the name of every playlist
set count_pl to count the_playlists
end tell

tell application "iTunes"
--used for now because "frontmost" activates quickeys
--tell frontmost
set the_choice to choose from list the_playlists with prompt "Pick a Playlist:"
end tell

tell application "iTunes"
set the_pl to item 1 of (every playlist whose name is the_choice)
set the_total to count tracks in the_pl
set n to random number from 1 to the_total --use for random track
--set n to 1 ---use for non-random track
play track n of the_pl
end tell
on error error_message number error_number
if the error_number is not -128 then
error number -128
end if
end try

[ Reply to This | # ]
command <- and command ->
Authored by: rebug on Apr 16, '02 04:43:16PM

Those keys switch terminals in Terminal and go to Beginnning / End of line in BBEdit. Other than that, I don't think anything uses them.

Still a good tip, though.

[ Reply to This | # ]
Authored by: pecosbill on Apr 25, '02 04:51:23PM

Actually, those keys are universal in all applications to go to the beginning/end of a line. (It's been a standard forever on the Mac.)

[ Reply to This | # ]
F keys
Authored by: litedoctor on Apr 16, '02 11:51:45PM

F key settings in X take their cue from 9's control panel. So boot up in 9, set the keys you want, and they'll be available in X

[ Reply to This | # ]
F keys
Authored by: DougAdams on Apr 20, '02 07:26:19PM

How did you get this to work?

[ Reply to This | # ]
Authored by: parkov on Apr 17, '02 02:09:50PM

Which control panel do you go to in OS 9 to assign F keys?

Also, is there a way to keep the AppleScripts open and hidden? Wouldn't that make the response time even shorter than having them start up every time you want to skip a track?

[ Reply to This | # ]
Authored by: litedoctor on Apr 17, '02 07:06:09PM

The control panel in 9 is Keyboard.

[ Reply to This | # ]
iTunes prev/play/next buttons
Authored by: mervTormel on Apr 17, '02 05:14:52PM

with the iTunes window maximized (minimized) to the small player window, the previous/play/next buttons do not cause an application context switch. the mouse click is 'passed thru' to the application.

in fact, many widgets act this way. you can close/minimize/maximize windows in background layers without the layer context switch.

[ Reply to This | # ]
Scripts Menu or OSA menu...
Authored by: DougAdams on Apr 20, '02 07:24:41PM
...gets the job done, too. Plus, using either of those, you can save your scripts as Compiled and they will run faster than as Apps. Doug Doug's AppleScripts for iTunes

[ Reply to This | # ]