0

Under Win2K(or later), by sending a Virtual-Key VK_LAUNCH_MEDIA_SELECT, can start a player.

If more than one player software installed, how to determine which one it will start?

A sample VBS code:

Wscript.CreateObject("Wscript.Shell").Sendkeys chr(&h88b5)

http://msdn.microsoft.com/en-us/library/windows/desktop/dd375731(v=vs.85).aspx

http://msdn.microsoft.com/zh-cn/library/dd375731

VK_LAUNCH_MEDIA_SELECT
0xB5
Select Media key
neorobin
  • 139
  • 1
  • 6

3 Answers3

1

VK_LAUNCH_MEDIA_SELECT is actually received by the system and translated into a WM_APPCOMMAND with lParam as APPCOMMAND_LAUNCH_MEDIA_SELECT. So theoretically, any program implementing a handler for this could be launched. This page (albeit old) lists default applications which listen for WM_APPCOMMAND:

  • Internet Explorer
  • Windows Help
  • DVD Player
  • CD Player
  • Media Player
  • Volume Control system tray applet

Obviously, only a few of those are actually applicable for APPCOMMAND_LAUNCH_MEDIA_SELECT.

However, I don't know how the translation mechanism actually works. It appears not every application will receive the translated WM_APPCOMMAND message. On my keyboard, I tried pressing the button which sends VK_VOLUME_UP. The volume goes up as expected because it is handled by the volume control system tray applet. However, I opened an instance of notepad.exe and monitored its messages with Spy++. It did not receive any message even when it was in the foreground. Curiously, VK_MEDIA_PLAY_PAUSE is received through WM_APPCOMMAND if the play/pause button is pressed as long as notepad.exe had the focus. I would test with VK_LAUNCH_MEDIA_SELECT, but I'm not actually sure what button that corresponds to (or whether my keyboard has it).

Mike Kwan
  • 24,123
  • 12
  • 63
  • 96
  • Thank you for your feedback. On my testing, sending the Virtual-Key VK_LAUNCH_MEDIA_SELECT is by VBS: Wscript.CreateObject("Wscript.Shell").Sendkeys chr(&h88b5) Set the default association for the CDA (CD Audio) files to Notepad or Paint or any other program, it can still send the same virtual key to open the corresponding program. – neorobin May 02 '12 at 17:38
1

Thanks, for Mike Kwan's reply.

Through testing a lot of settings a program associated with a variety of audio files. Finalized, this will depend on the CDA (CD Audio) files associated with which program.

If you set the default association for the CDA (CD Audio) files to Notepad or Paint or any other program, it can still send the same virtual key to open the corresponding program.

neorobin
  • 139
  • 1
  • 6
1

The foreground window can do whatever it wants in response to the WM_APPCOMMAND message, if it does not handle the message then shell hooks (HSHELL_APPCOMMAND) gets to handle it, if no hooks handle the message then Windows checks the AppKey key in the registry. (You can use Process Monitor to find the number for a specific key-press)

Anders
  • 97,548
  • 12
  • 110
  • 164