Intercepting 'multimedia keys'

  • Thread starter Thread starter Steve McLellan
  • Start date Start date
S

Steve McLellan

Hi,

Does anyone know if it's possible (and if so, how) to intercept presses on
'multimedia keys' you find on keyboards? Curiosity more than anything. Only
manufacturers seem to put their own random gubbins onto their keyboards, so
presumably there isn't any kind of standard. Obviously their applications
are capable of listening to the buttons so it's possible at some level.
Possibilities in either .NET or Win32 welcome (hence the cross post -
apologies).

Cheers!

Steve
 
Steve McLellan said:
Does anyone know if it's possible (and if so, how) to intercept presses on
'multimedia keys' you find on keyboards?

If the vendor is playing by the rules and if the o/s in question is ME, 2K,
XP or 2K+3, the simple thing to do is to respond to the WM_APPCOMMAND
message. At that point the keyboard software has mapped the keystroke
message into an application command like "Play" for example.

The standard keys on the enhanced keyboards are defined in <winuser.h>:

#define VK_BROWSER_BACK 0xA6
#define VK_BROWSER_FORWARD 0xA7
#define VK_BROWSER_REFRESH 0xA8
#define VK_BROWSER_STOP 0xA9
#define VK_BROWSER_SEARCH 0xAA
#define VK_BROWSER_FAVORITES 0xAB
#define VK_BROWSER_HOME 0xAC

#define VK_VOLUME_MUTE 0xAD
#define VK_VOLUME_DOWN 0xAE
#define VK_VOLUME_UP 0xAF
#define VK_MEDIA_NEXT_TRACK 0xB0
#define VK_MEDIA_PREV_TRACK 0xB1
#define VK_MEDIA_STOP 0xB2
#define VK_MEDIA_PLAY_PAUSE 0xB3
#define VK_LAUNCH_MAIL 0xB4
#define VK_LAUNCH_MEDIA_SELECT 0xB5
#define VK_LAUNCH_APP1 0xB6
#define VK_LAUNCH_APP2 0xB7

So, to answer your question "to intercept" them you could filter them while
processing WM_KEYDOWN which I think is what is done on 95 and 98. But you
may end up tripping over the keyboard manufacturer's software (like
Intellimouse, say) if you do that.
Curiosity more than anything.

As Martha might say, curiosity is a good thing. <g> If you curiosity is not
yet sated, you might want to take a look here:

http://www.microsoft.com/whdc/device/input/w2kbd.mspx

Regards,
Will
 
If the vendor is playing by the rules and if the o/s in question is ME, 2K,
XP or 2K+3, the simple thing to do is to respond to the WM_APPCOMMAND
message. At that point the keyboard software has mapped the keystroke
message into an application command like "Play" for example.

In order, probably not, yep and OK.
The standard keys on the enhanced keyboards are defined in <winuser.h>:

So, to answer your question "to intercept" them you could filter them while
processing WM_KEYDOWN which I think is what is done on 95 and 98. But you
may end up tripping over the keyboard manufacturer's software (like
Intellimouse, say) if you do that.

They'd better not get in my way! :-) Their software falls over all the time
like a twig in a stiff breeze anyway...
As Martha might say, curiosity is a good thing. <g> If you curiosity is not
yet sated, you might want to take a look here:

http://www.microsoft.com/whdc/device/input/w2kbd.mspx


Martha is, I'm afraid, lost to transatlantic language barrier or my total
lack of sleep :-) Thanks for the link - it looks... 'comprehensive' :)

Thanks!

Steve
 
Watch out for the volume level changing keys, they are often abused (that's
how I see at least) to control the master level when put on speakers. Many
of the users feel confused and start searching for your support email
address if your application happens to trap them to change its own private
sound level, as applications should for good behaviour.
 
William DePalo said:
If the vendor is playing by the rules and if the o/s in question is ME, 2K,
XP or 2K+3, the simple thing to do is to respond to the WM_APPCOMMAND
message. At that point the keyboard software has mapped the keystroke
message into an application command like "Play" for example.

On further investigation, it would appear that they're not playing by the
rules (or at least I'm not getting any APPCOMMAND message)... the bounders!
Oh well, I shall investigate further another time...

Steve
 
Steve McLellan said:
On further investigation, it would appear that they're not playing by the
rules (or at least I'm not getting any APPCOMMAND message)... the
bounders!

In that case you might want to have the Spy++ utility search for WM_KEYxxx
messages to all windows in the system.
Martha is, I'm afraid, lost to transatlantic language barrier or my total
lack of sleep :-) Thanks for the link - it looks... 'comprehensive' :)

Sorry. That's Martha Stewart, domestic diva, who is known to say "That's a
good thing."

Regards,
Will
 
Steve McLellan said:
In that case you might want to have the Spy++ utility search for WM_KEYxxx
messages to all windows in the system.

OK, will do.
Sorry. That's Martha Stewart, domestic diva, who is known to say "That's a
good thing."

That's very positive. All our lifestyle divas seem to hate everyone (shows
like "What the hell are you wearing" and "Are you serious? You LIVE like
this?"). Odd. Ok, thanks for the tip... the quest continues!

Steve
 
Gabest said:
Watch out for the volume level changing keys, they are often abused (that's
how I see at least) to control the master level when put on speakers. Many
of the users feel confused and start searching for your support email
address if your application happens to trap them to change its own private
sound level, as applications should for good behaviour.

Hi,

I agree, they should. Fortunately, what I'm doing will hopefully never be
seen by anyone :-) It's just to satisfy my curiosity really. Thanks for the
tip though, definitely something to watching out for.

Cheers!

Steve
 
William DePalo said:
In that case you might want to have the Spy++ utility search for WM_KEYxxx
messages to all windows in the system.

That proved to do the trick... it appears Compaq have done away with all the
niceties and present a virtual key code of 00FF and scan code of <various>
for the 'special' keys, at least for this keyboard. Naughty!

Thanks for your help!

Steve
 
All of these devices use HID (human interface device). You can open these
devices directly (at least the multi-media buttons, the keyboard keys are
opened securely by Windows). You can then use the HidP and HidD APIs to
crack the reports.
Another option is to use WM_INPUT.

For details on using these APIs, see MSDN (look for WM_INPUT), or the
hclient sample in the DDK.
There are also several books written that include details on HID.

Randy
 
Back
Top