Keyboard Media Controls for Windows With AutoHotKey




Introduction: Keyboard Media Controls for Windows With AutoHotKey

This is my entry for the Art of Sound contest.

This instructable will detail how to create a set of keyboard shortcuts for Windows XP/Vista that allow you to pause, play, stop and skip tracks in your media player without having to navigate to the media player first. This is useful when using a keyboard that doesn't have media buttons.

Often when I want to pause my music, it's to talk to one of my housemates or to answer the phone. I want to do it quickly without fumbling for my music player icon in the task bar/icon tray. This instructable will show you how to do just that and make it autostart when you turn your computer on.

I'm sorry the pictures aren't very exciting.

Step 1: Getting Started

You will need AutoHotKey, a free program that allows you to create powerful macros for Windows and compile them into an executable file that can be run on any PC even if it doesn't have AutoHotKey installed.

AutoHotKey - can be downloaded from here
A text editor - I use Crimson Editor but any will do

Once you have installed AutoHotKey, right click anywhere on your desktop and select 'New' then 'AutoHotKey Script' (picture 1). Name the .ahk file something informative so you won't forget what it is.

Step 2: Writing the Script

Open your .ahk file in a text editor of your choice.

We'll be using four of the commands AutoHotKey has relating to media control and assigning these keyboard shortcuts. You need to choose keyboard shortcuts that aren't going to be used accidentally. 'A' for example would be a poor choice as you'd be pausing/playing your music every few seconds while typing! You also need to consider whether the keyboard shortcut is used for anything else, as AutoHotKey would stop this from functioning.

I chose to use the shift key with F1-F4.

Play/pause: shift + F1
Stop: shift + F2
Previous: shift + F3
Next: shift + F4

This will let me pause with only one hand, and with either hand by holding the shift button and pressing F1, F2, F3 or F4. This page on the AutoHotKey website shows a list of all the other things you can send instead of arrow keys if you wish.

The code to make the magic happen: (lines beginning with a ';' are comments)

;next song
+F1:: ;the + means shift
Send {Media_Next}

;previous song
Send {Media_Prev}

Send {Media_Play_Pause}

Send {Media_Stop}

Step 3: Running the Script

Before compiling the script, right click it and click 'Run'. This will let you check it works. (picture 1)

Check your script works. If something unexpected happens, there is a small icon in the icon tray, right click it and press 'exit'.

If all goes well, right click and press 'Compile'. This will give you a .exe file you can run on any computer.

Step 4: Running on Startup

Finally, you'll want the script to be started each time your computer starts. This way the functionality is always there.

1) Click 'Start', click 'All Programs', right click 'Startup', click 'Open'
2) Make a shortcut to your compiled script
3) Copy the shortcut into the startup folder. This will make it run on startup.

Participated in the
Art of Sound Contest

Be the First to Share


    • Exercise Speed Challenge

      Exercise Speed Challenge
    • Pocket-Sized Speed Challenge

      Pocket-Sized Speed Challenge
    • Super-Size Speed Challenge

      Super-Size Speed Challenge

    2 Discussions


    2 years ago

    Thank you so so much


    10 years ago on Introduction

    Thanks a lot, found a list here ( for Winamp controls. :)