Here is my script for controlling iTunes:
Infortunately, it does not work when iTunes is minimized or chilling in the tray, but if you just have it hiding behing whatever your working on, it works fine. Enjoy!
/*
---------------------iTunes Helper----------------------------
------------------------by Veovis-----------------------------
Control iTunes from any program, even full screen ones. Use the
Song Selector to choose what song to play, and the commands to
play,pause,skip songs, or change volume.
.-= Song Selector =-.
Hotkey: Ctrl /
Press the hotkey, type something, then press enter (or wait for
the 5 second timeout) and iTunes will perform a search and play
all songs that have your critia in the name, artist, album, etc.
So typing aquabats will play all songs by the aquabats, and
"aqua charge" would play all songs by aquabats in album charge.
.-= Commands =-.
Hotkey: Ctrl . (period)
Press ctrl . to have the computer listen for one of the following:
- space Play/pause current song.
- p Start song over (type 2p to play previous song)
- n Play next song.
- shift p Play previous album.
- shift n Play next album.
(in the following # means NUMBERS not WINKEY)
- #p/#n/#P/#N Go forward/back # songs/albums
If you type a number, then p,n,P or N then iTunes will go
forward/back that many songs/albums, for ex: 6n would go
forward six songs and 2P will go back 2 albums
- # enter If you type a number between 0 and 100 and press
enter it will set the iTunes volume to the nearest
5%. So pressing 37enter will set it to 35.
- escape Cancel
For Example:
Pressing: Does:
{ctrl}/aquabats Plays all songs that match "aquabats" (using iTunes search)
{ctrl}.{space} Play/pause
{ctrl}.p Previous song
{ctrl}.n next song
{ctrl}.{shift}p Previous album
{ctrl}.{shift}n Next Album
{ctrl}.4p go back 4 songs
{ctrl}.5{shift}n go forward 5 albums
{ctrl}.50 Set volume to 50%
*/
#singleinstance force
#NoEnv
SendMode Input
SetFormat,float,0.0
SetKeyDelay 25
StringCaseSense, On
^/::
Input, UserInput, T5,{enter}{escape}
ifequal,userinput,, return ;if no input, dont continue
ifequal,errorlevel,EndKey:Escape,return ;if you press escape dont do anything
controlsend,edit1,{esc},iTunes ;this fixes a bug if your last search returned nothing
loop, 2 ;dont know why this is necesary, just dont remove it
{
controlsettext,edit1,%userinput%,iTunes
controlsend,,{enter}{tab}{down}{enter},iTunes
}
return
^.::
Input,command,C t3 *,{enter}, ,p,n,P,N
if errorlevel = Match
{
stringright,key,command,1
stringtrimright,count,command,1
if key = %A_space%
controlsend,ahk_parent,{space},iTunes
if key = p
controlsend,ahk_parent,{left %count%},iTunes
if key = n
controlsend,ahk_parent,{right %count%},iTunes
if key = P ;previous album
controlsend,ahk_parent,+^!{left %count%}{alt up}{control up}{shift up},iTunes
if key = N ;next album
controlsend,ahk_parent,+^!{right %count%}{alt up}{control up}{shift up},iTunes
}
if command = 0
controlsend,ahk_parent,^+{down}{shift up}{ctrl up},iTunes
else if command = 100
controlsend,ahk_parent,^+{up}{shift up}{ctrl up},iTunes
else if (command > 0) and (command <= 50)
{
steps := round(command*2,-1)/10
volume := steps*5
controlsend,ahk_parent,^+{down}{shift up}{ctrl up},iTunes
controlsend,ahk_parent,^{up %steps%}{ctrl up},iTunes
}
else if (command > 50) and (command < 100)
{
steps := round((100 - command)*2,-1)/10
volume := 100 - steps*5
controlsend,ahk_parent,^+{up}{shift up}{ctrl up},iTunes
controlsend,ahk_parent,^{down %steps%}{ctrl up},iTunes
}
return