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.
Post a Comment