The trouble is how to exactly go about this. Even if you know these scripting languages, how do you know which commands to send to iTunes? As I always wanted a dead simple alarm clock function using iTunes and Windows Task Scheduler, I wrote a short script that I could run each morning:
- Enter the following script:
Set objApp = CreateObject("iTunes.Application")
Set colSources = objApp.Sources
Set objSource = colSources.ItemByName("Library")
Set colPlaylists = objSource.Playlists
Set objPlaylist = colPlaylists.ItemByName("Party Shuffle")
(above should be 6 rows only in your script)
You can change “Party Shuffle” to preferred playlist, but then you would have to wake up to the same sequence of songs every morning. You could also add a:
objApp.Shuffle = 1
in the script to turn on shuffling, but the first song will still be the same. Party Shuffle will always pick up where you last played it.
- Try the script by double-clicking it from Windows Explorer or your desktop. It should start iTunes (if not already started), and start playing. If another program opens your script, you have not associated .vbs to Windows Scripting Host. Re-associate, or create a shortcut to: “wscript.exe <your path to you script in quotes>”.
- Now, you just have to schedule your alarm clock. Go to Windows > Accessories > System Tools > Scheduled Tasks. Start it. For simplicity, put a shortcut to it on your desktop or in your task bar. Go through the “Add Scheduled Task” wizard, and point it to your script (or wscript shortcut, if you had to do one). You can easily customize the times of the schedule, to happen only on week days, every day, every other day, etc. If you have different times every day, you can add separate schedules for the same task.
- After finishing the wizard, make sure you right-click on the task and go to Properties > Settings and click “Wake the computer to run this task”. The nice thing about Task Scheduler is that it can wake up your computer to for the alarm. Yes, that is right, you can hibernate or go into standby all night (do that, it will save us from some global warming) and let the computer wake up by itself. To make sure this works smoothly, also enter your Windows password under “Run As” in Properties > Task.
- Before trusting your alarm completely, set the task (or a new copy of the task) to run a few minutes later and hibernate the computer. Then wait until the time you set to make sure it actually manages to go all the way. Different people have different programs installed, and some might theoretically stop the Task Scheduler from running. For example: IBM-Lenovos Client Security Solution will replace the Windows authentication with its own, forcing you to manually unlock the computer before any program can run :p
That should be all. You now have your iTunes alarm clock! You can, of course, do lots of other stuff. For example – if you have a program that translates any hot key to a command, you can make scripts for going to next and previous track, play/pause and similar. To get some good ideas, check this Microsoft article out. There is also some info here and here. Finally, do you have an idea for a script that none of these articles seem to describe? Download the Apple SDK, open the zip file and then open the iTunesCOMInterface.h file. Don’t be scared by all the C code – just search through it (for example, you want to activate Repeat, search for “repeat”). The name of the methods in the C code are most of the time identical to, or similar to, the commands you need to write in your script. Good luck!