This script lets you create reliable hotkeys for iTunes that work anywhere, including when iTunes is minimized to the tray. It uses sean's COM lib to connect to iTunes to control it and get info from it.
Just Download the .7z or peek at the iTunes.ahk file, though you'll need the other files in the 7z.
This requires sean's COM lib. I recommend it be put in your standard lib, but you could also #include it
These are the hotkeys I use. Also a good demostration of possibilities.
Disclaimer: Neither AHK nor I am in no way liable for any damages resulting from this script giving you a feeling of complete power or sense of limitless, god-like control.
#.::iTunes("NextTrack") #,::iTunes("PreviousTrack") #'::iTunes("SoundVolume", "+", 2) #;::iTunes("SoundVolume", "+", -2) #=::iTunes("FastForward"), WaitThisHotkey(), iTunes("Resume") #-::iTunes("Rewind"), WaitThisHotkey(), iTunes("Resume") #/::iTunes( "Mute", "!" ) #Space::iTunes("PlayPause") #Backspace::iTunes("Stop") #Up::iTunes("CurrentTrack.Rating", "+", 20) #Down::iTunes("CurrentTrack.Rating", "+", -20) ; more useage examples: iTunes( "SoundVolume", "", 25 ) ;set the sound directly to 25 iTunes( "SoundVolume", "+", 10 ) ;add ten to the current soundvolume. you can "add" a negative too iTunes( "Mute", "!" ) ;toggles the mute state iTunes( "PlayFirstTrack" ) ;plays the first song in the current playlist iTunes( "SongRepeat", "", 2 ) ;song repeat mode: 0=Play playlist once, 1=Repeat song, 2=Repeat Playlist iTunes( "PlayFile", "", "D:\Full\Path\To\FileToPlay.ext" ) ; cool, eh? iTunes( "Quit" ) ; uhm, do i really have to tell you this? #Include iTunes.ahk WaitThisHotkey() { ; by Infogulch ~ http://www.autohotkey.com/forum/topic35999.html RegEx := RegExMatch( A_ThisHotkey, "i)(?:[~#!<>\*\+\^\$]*([^ ]+)( UP)?)$", Key) KeyWait, %Key1%, % (Key2 ? "D" : "U") }
Well, that's the "Control" part, what about the "Info"? First, the Info part is optional, and you don't have to use it if you only want to use the control part. After you start it up, it will fade in and display informaiton about the current playing song. It will then briefly and unobtrousively fade in and out whenever the track changes. Honestly, it may be best for shuffle mode when you may not know what song comes up next. But along with something like changing the rating or fast forwarding, it allows you to see what you're doing without having to open iTunes.
Screenshot:
Resources: I got ideas for much of what's coded here from what's in these links.http://www.autohotke...opic.php?t=5727
http://www.microsoft...zone/tunes.mspx
http://developer.app...unescomsdk.html (unfortuneately, this sdk is primarialy for iT 7x, and not all functions listed work in iT 8 )
Revision History:1.0 ~ initial release. Used WS4AHK as COM workaround.
2.0-2.2 ~ unreleased. 90% rewrite, port to sean's COM lib, debug
2.3 ~ current release. Fixed bugs.Comments:
Though it isn't too dramatic of a visual change, the entire underlying methods of getting and controlling iTunes have changed. With COM comes the ability for iTunes to notify the script of certian events that happen. This allows for less overhead than the previous versions, which basically polled iTunes waiting for different information. WS4AHK has other overhead as well, since I used JS or VBS as a middleman to iTunes' COM functionality. This was also done away with. Hopefully, this script can benefit you iTunes users out there, but even if not, it is a good example of the possibilities of the COM.
The main goals I have for this is an easy to use control of iTunes with an intuitive use of a gui for showing currently playing song info. All of this while being as inobtrousive as possible to the script itself, so I avoided loops and dramatically shortened any timers I had, as well as only creating a total of 10 global vars. So it comes out, intentionally, a script very much intended to be #included into another main script. I just want that possibility to be available.
Credits: Sean for his excellent COM lib, various threads around the forums for giving me ideas and encouragement for possibilities, any pre release testers.
If you use iTunes, I encourage you to try it out! And then tell why you like it! (Or don't) If anybody has any suggestions, I'd love to hear them.
Thanks for looking.