Saturday, January 12, 2008

Configuring Keyboard Multimedia Keys Without Special Drivers

Most keyboards sold today have some or the other extra keys. The interesting thing is that in most cases, these keys continue to work even after any and all proprietary drivers have been removed from the system. I should know, I run a minimalist Windows XP system with just 17 services started by default, even less if I dont want to get any files off the network etc.

So how do these keys continue to work? Well according to a very interesting thread I found, support for this is part of Windows itself. You can read more about it here, here and here.

This whole structure is part of Windows' AppCommands set. AppCommands specify a standard set of additional keys that can be present in a multimedia keyboard and default handlers for the same inside of Explorer itself.

With a little bit of digging I found a splendid program which will show you multimedia keys being pressed on your keyboard. Based on the program, here is the list of AppCommands:

Command Name Description
1 APPCOMMAND_BROWSER_BACKWARD Navigate backward.
2 APPCOMMAND_BROWSER_FORWARD Navigate forward.
3 APPCOMMAND_BROWSER_REFRESH Refresh page.
4 APPCOMMAND_BROWSER_STOP Stop download.
5 APPCOMMAND_BROWSER_SEARCH Open search.
6 APPCOMMAND_BROWSER_FAVORITES Open favorites.
7 APPCOMMAND_BROWSER_HOME Navigate home.
8 APPCOMMAND_VOLUME_MUTE Mute the volume.
9 APPCOMMAND_VOLUME_DOWN Lower the volume.
10 APPCOMMAND_VOLUME_UP Raise the volume.
11 APPCOMMAND_MEDIA_NEXTTRACK Go to next track.
12 APPCOMMAND_MEDIA_PREVIOUSTRACK Go to previous track.
13 APPCOMMAND_MEDIA_STOP Stop playback.
14 APPCOMMAND_MEDIA_PLAY_PAUSE Play or pause playback.
15 APPCOMMAND_LAUNCH_MAIL Open mail.
16 APPCOMMAND_LAUNCH_MEDIA_SELECT Go to Media Select mode.
17 APPCOMMAND_LAUNCH_APP1 Start App1.
18 APPCOMMAND_LAUNCH_APP2 Start App2.
19 APPCOMMAND_BASS_DOWN Decrease the bass.
20 APPCOMMAND_BASS_BOOST Toggle the bass boost on and off.
21 APPCOMMAND_BASS_UP Increase the bass.
22 APPCOMMAND_TREBLE_DOWN Decrease the treble.
23 APPCOMMAND_TREBLE_UP Increase the treble.

New commands introduced with Windows XP include:

Command Name Description
24 APPCOMMAND_MICROPHONE_VOLUME_MUTE Mute the microphone.
25 APPCOMMAND_MICROPHONE_VOLUME_DOWN Increase microphone volume.
26 APPCOMMAND_MICROPHONE_VOLUME_UP Decrease microphone volume.
27 APPCOMMAND_HELP Open the Help dialog.
28 APPCOMMAND_FIND Open the Find dialog.
29 APPCOMMAND_NEW Create a new window.
30 APPCOMMAND_OPEN Open a window.
31 APPCOMMAND_CLOSE Close the window (not the application).
32 APPCOMMAND_SAVE Save current document.
33 APPCOMMAND_PRINT Print current document.
34 APPCOMMAND_UNDO Undo last action.
35 APPCOMMAND_COPY Copy the selection.
35 APPCOMMAND_REDO Redo last action.
37 APPCOMMAND_CUT Cut the selection.
38 APPCOMMAND_PASTE Paste
39 APPCOMMAND_REPLY_TO_MAIL Reply to a mail message.
40 APPCOMMAND_FORWARD_MAIL Forward a mail message.
41 APPCOMMAND_SEND_MAIL Send a mail message.
42 APPCOMMAND_SPELL_CHECK Initiate a spell check.
43 APPCOMMAND_DICTATE_OR_COMMAND_CONTROL_TOGGLE Toggles between two modes of speech input: dictation and command/control (giving commands to an application or accessing menus).
44 APPCOMMAND_MIC_ON_OFF_TOGGLE Toggle the microphone.
45 APPCOMMAND_CORRECTION_LIST Brings up the correction list when a word is incorrectly identified during speech input.

How to make use of these commands? Well you can add or modify registry keys. For e.g., (from the thread) the mail key usually launches the default mail app.

HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\AppKey\15\RegisteredApp = "Mail"

If you want to replace this to open Notepad,

HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\AppKey\15\ShellExecute = "notepad.exe"

(Or change HKLM if you want to modify for all users etc)

RegisteredApp means the app registered for that function will be called. (Like Mail above)

Association Means the app associated with a particular file type will be opened. For e.g. the Media key is registered by default to .cda, meaning the default app used for playing music CDs will be opened on pressing that key.

ShellExecute opens a particular program to be run.

BTW, if you do not know what HKLM and HKCU means, know that they relate to the registry. Editing the registry is very dangerous and you may destroy your windows installation if you mess it up. Be Careful! Phew... That is out of the way :) Interestingly for registry changes, these ones do not require a restart!!

Of course, the simplest way to edit these properties safely is use the TweakUI powertoy from Microsoft. Simply go to Explorer>Command Keys and alter to your heart's satisfaction! Just two caveats:
1. As you type in text, it automatically tries to find the matching folder path. The annoyance is that when you actually try to save, it says the "Program Does Not Exist". This usually means you are trying to run a program with spaces etc in the path. Simply wrap the program name with a quotes, such as "e:\Program Files\Winamp\CLAmp.exe" /playpause.
2. The Play/Pause button is not listed and even editing the registry to make AppCommand 14 call CLAmp does not work. Play/Pause seems uncustomizable right now, if anyone knows why, please do tell me. Funny though it still Pauses Window Media Player, almost as if WMP was locking that command ;)

Nice... So now I can pause/resume my Winamp using the Media key on my keyboard using CLAmp :)

Hmm... Makes me wonder why I need those bloatware drivers from M$ and Logitech.

23 comments:

Steven said...

Very interesting and informative. I've been searching for information on this because of a new program I've installed has latched onto my media keys...so when ever skip a song in winamp, i open or close this other program.

I tried adding key 11 to see if it had multiple entries...but it just seemed to create a default folder.

I have very little experience with editing the registry so if you could share a little more information regarding how to add these additional keys to the registry I would be over the moon :P

Cheers,
Steven

MoGlee said...

Well first off, try using the TweakUI power toy. (I have linked to it in my post) Inside TweakUI, expand "Explorer" on the left and then click on "Command Keys". This should allow you to modify the action for a particular key as per your wishes.

If TweakUI doesn't work, ping me and I will give you some more information on editing the registry...

Steven said...

Sorry, i forgot to mention i did pick up TweakUI, but it doesn't seem to have media key options, it has everything but pause/play previous track/next track. Quite handy for other things, but not what I'm after at the moment.

Steven.

MoGlee said...

In that case, you can check out these links to learn more about editing the registry:
Editing the Windows Registry
Registry Information from Microsoft
HKLM means HKEY_LOCAL_MACHINE and HKCU means HKEY_CURRENT_USER by the way. The easiest way to edit the registry is to open regedit, navigate to the relevant key and then modify it as you see fit.

Inside regedit, the left pane shows keys while the right one shows the values associated with that key.

The first link above has much more information on basics of editing the registry, I think if you go through it once, you should have no trouble :)

Steven said...

Hey Moglee,
I checked out those sites and didn't really get anything new from them, i think i managed to add the key correctly, but it doesn't show any associations for them. I don't think there is much more i can try. I just wanted to say thanks for the help, i appreciate you taking the time :)

Cheers,
Steven

Anonymous said...

Thank you for your informative post- I was looking for this exact info...
Funny you should mention Winamp, cause I was trying to get it resolved too and what I found out was that Winamp has its internal hotkey/multimedia key support - yeah its that easy - just go to Options-Preferences-Global Hotkeys- should work like a charm, at least it worked for me - Good luck!

MoGlee said...

Glad to be of help! Nice tip on Winamp. Now I have that enabled too :)

Bert said...

Great, now if someone can tell me how to remap my volume mute button into a microphone toggle button, I'd be very happy.
First obviously I need to add the registry key 8, but what value to put in it so it remaps to 44?

Anonymous said...

Some good information here, thanks.

Is there a way to map these commands to a normal key press combination (rather than the media keys), ie I'd like to map mute/unmute of the microphone to CTRL+M or the windows key+M.

Or is there a format for putting it in a batch file ?

I have a voice dictation PC that frequently seems to mute it's mike volume, and need some easy way for non-technical people to re-enable the mic.

MoGlee said...

You can use SharpKeys or AutoHotKey

JeeZ said...

Even better ... there's a winamp plug-ins made exactly for that :
http://www.winamp.com/plugins/details/78516

It works with my Dell Media keyboard. Should work with the Logitech one two, since it was designed for it :)

Have fun!

Global Misadventures said...

I have a Microsoft Wireless Desktop Elite and I am trying to get the media button to act as a microphone mute key. There is no option in the intellitype menu so I have resorted to find another solution which brought me to this forum. I cant seem to make it work through Tweak UI, so I have been racking my brain to get it done in the registry..but I am not sure what I need to put in. any help would be appreciated. Thanks

MoGlee said...

I would suggest using TweakUI, which does have media key mapping (Explorer > Command Keys > Media). Now the problem is that you can either run the default action, or you can run a program. So obviously, we need a program to mute and unmute for us. You can download such a utility here and map the key to it. Some more useful programs from the same developer can be found here

clazie said...

I looked at both of those and they are actually great programs. Is there a way to alter them to control the mute on the microphone? I have a mute key already for the sound. Thanks for the suggestions thus far and thanks for your future help.

MoGlee said...

That's an interesting problem; I doubt there is an easy/generic way to do that. See when playing back sound, the output only goes to one thing (say the speakers; well technically, a sound device) Accordingly its possible to mute the speakers, thus there is a concept of "mute". When you record, you are getting data from a source and putting it into another source. So technically, there is no "mute" for recording. Some applications (Skype) allow you to mute microphone... that doesnt really mute the microphone, it simply means that application stops processing input from the microphone, thus pretending its mute. Another application however, should still be able to recieve input from that microphone. You can try disabling the input device using devcon. I haven't tried it and I have no idea if it will work. Alternately, you will have to look at app specific shortcuts. Just like Winamp supports global hotkeys, so does Skype.

Wiky said...

Hi everyone.
Is there any way to configure keys such as AltGr+1 to stop the music at Windows Media Player or one of the F's?
What i'd like to do is configurating F5 or AltGr+1 to stop, F6 or AltGr+2 to Go back to the previous track, F7or AltGr+3 to play/pause the music and F8 or AltGr+4 to skip the track.
Thanks to everyone, Best Regards,
. Wiky5

MoGlee said...

Try AutoHotKey. The tips here are mostly for reconfiguring the additional keys already present in your keyboard. Say you have a Play/Pause key, you can use what I blogged about to make it do something else. To turn a normal keystroke into a action, AutoHotKey is the best :)

Kris said...

Can you help me?
I have a USB keyboard with 9 media keys and volume wheel. When I first plugged it in, my computer installed the drivers and the media keys worked. I then shut down my PC overnight but when I restarted it the following day the media keys didn't work. I unplugged the keyboard and tried a different USB port and they worked again but the same thing happened when I shut down my PC and restarted again, they stopped working. Something at start up or in the registry or somewhere is not enabling them...

Any ideas on how to fix this?

Many thanks

Anonymous said...

Are you aware of a Windows7 equivalent to TweakUI. I have a new Gateway laptop that shipped with Vista 64bit, but also came with a free upgrade to Windows 7. After doing a raw install of Windows 7, two of the quick launch soft touch keys stopped working. I believe the keys are intended to launch my preferred music app and preferred DVD player. Gateway support was absolutely useless.

Rick said...

Thanks, I was looking for the right registry keys to change to fix my media launch key.

Now I can launch winamp. I assume my .cda default changed to something else, so I just set it to .mp3 which I know defaults to winamp.

Cheers!

Fernando said...

Very informative and, above all, useful. There's no equivalent in Windows 7 (that I've found) to XP's TweakUI key editor (W7's version does not feature that).

Thank you very much for publishing this list :)

Unknown said...

Works fine in windows 10. My "LAUNCH_MAIL" button now launches "SnippingTool.exe /clip" from my fairly new "gk-force k83" with its "Hot-link Function Keys". "LAUNCH_APP2" defaulted to launch Calculator, but now it launches Opera. I'll probably find something better for that and "LAUNCH_MEDIA_SELECT". I might leave "LAUNCH_APP1" on Task Manager, but there already is CTRL-Shift-Esc.

Cocktails in Copenhagen said...

The list is informative in locating hotkeys. However I am wobdering if anyone knows what you can change the keys to?
e.g. I've located the registry command 7, which launches my browser/navigates home. However I would like this button to instead refresh the current window. How would I go about changing that?