Coretron’s Tech Blog

March 23, 2009

Avoid repetition, simplify common tasks and more with AutoHotKey

Filed under: Technology — coretron @ 2:55 pm

Lately I’ve been downloading and sorting 15,000 songs for our new karaoke setup. I’m using the modded xbox with Xbox Media Center to play the .cdg files. I got this karaoke mixer as well as two shure mics for under $100 after shipping. I’ve found about 50 torrents of karaoke songs. The problem now is I want all the file names to be in the format “artist – song name.cdg” About one third are in that format, one third are in “song name – artist” and another third are “disc number – artist – song name”. Fortunately the disc numbers are all the same length so I figured the best way to delete the first 15 characters of a file name would be to get a program that can loop keyboard commands. I found this open source program called AutoHotKey which turns out to be awesome. After figuring out how to use it I made a file called task.ahk, in here its almost like a simple programing language. You can use commands like if this programs open do this, if not run the program and do it. “Send” will send keystrokes or keys in brackets like {tab} or {space}. Sleep tells it to wait a specific amount of time before proceeding in the script. You can even use “waitwin” command to wait till a specific program is done loading before continuing. It can do the same for websites too. Most importantly to me, it loops. After about an hour of looping the command to delete the disc number the task gets harder. 

There’s no easy way to move the song name to the end of the file name. I had about 8000 songs that needed this done.My initial thought was to outsource the project to India, but then I got an idea. I would have to manually go through and do it but have AutoHotKey do everything if could to help me. I had assigned numbers 1-9 to macros that would move the corresponding number or words to the end of the file name. Here’s what the script looked like for a one word song name. 1::Send, {HOME}{CTRLDOWN}{SHIFTDOWN}{RIGHT}{RIGHT}{CTRLUP}{SHIFTUP}{CTRLDOWN}x{CTRLUP}{END}{LEFT}{LEFT}{LEFT}{LEFT}{SPACE}-{SPACE}{CTRLDOWN}v{CTRLUP}{BS}{BS}{BS}{TAB}” The script also moves the dash between song name and artist to the correct spot. One key was finding how to select words using the keyboard rather than characters, this is done with control+shift+right. Since every song has two files (.mp3 and .cdg) I looped it once. So now I still have to go through and rename the files but now to rename “Piano Man – Billy Joel.mp3” to “Billy Joel – Piano Man.mp3” all I have to do is press 2. The things damn fast too, the entire command for .mp3 and .cdg is executed in about 1.5 seconds. For extra power you can go to task manager and give high priority to AutoHotKey. It’s gonna take about 4-5 hours of work but its worth it for the ultimate karaoke box. 

Every time I host a game of DotA I have to type out “/hostbnetpublic DotA v6.59c -RD USA!! LC!” and press enter. Now I can just press alt+h to host. Every task you do on a  regular basis should only take one command to execute. AutoHotKey has thousands of commands and functions it can execute to help you, I can guarantee its more complete and complex than you’ll ever need. Get it at



  1. if all you wanted to do was rename your mp3s, a simple mp3 tag and name editor program will do. There are hundreds of free ones floating around the internet.

    nonetheless, im sure there are other uses for this.

    Comment by Anonymous — March 23, 2009 @ 3:31 pm

  2. I had to rename the .cdg files as well as the mp3 files. Also, the mp3 files didn’t have any meta data for song name and artist.

    Comment by Coretron — March 23, 2009 @ 5:20 pm

  3. It’s 9’o’clock on a Tuesday…Regular crowd shuffles in…

    Comment by Dwiley — March 24, 2009 @ 8:04 am

  4. Take a knee. HAAHAHAHAHAHAH. nice. So you said this weekend D Dubbya? When exactly give a time.

    Comment by Scumbag J — March 24, 2009 @ 3:29 pm

  5. I’ll go to Cory and Chadd’s straight from work…so I should get there on Friday at 6:30ish? Maybe earlier if the warden isn’t paying attention!

    Comment by Dwiley — March 26, 2009 @ 7:45 am

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

Blog at

%d bloggers like this: