0

I have IBM ThinkPad notebook and PCMCIA sound card.

Volume control works only for integrated sound card. I want to fix it somehow by writing small application.

I tried to find codes of these keys like this:

private void Form1_KeyUp(object sender, KeyEventArgs e)
{
    labelKeyCode.Text = e.KeyCode.ToString();
}

However this is not working. Im not getting any codes. It looks like these keys are not part of "keyboard device".

Note: this code was just for code preview, in my application I want to use WINAPI for global keyboard capture.

How can I capture these keys?


Edit:

I tried to reverse-engineer a little, and I browsed "HKVOLKEY.dll" (file from IBM Hotkey software) with Dependency Walker, but i found only 2 function names there: RegisterVolumeHotkey and DeregisterVolumeHotkey.

Kamil
  • 13,363
  • 24
  • 88
  • 183

1 Answers1

0

I think your approach is wrong. But have look at this: Disable Keyboard globally for a WPF Window

As your input keys might be registered, but just not as regular input but as control keys.

Maybe this is of any use as well for a more direct approach: http://naudio.codeplex.com/

NAudio is an open source .NET audio and MIDI library, containing dozens of useful audio related classes intended to speed development of audio related utilities in .NET.

I've written a small piece of code once to mute all volumes using NAudio: Mute Windows Volume using C#

Community
  • 1
  • 1
Mike de Klerk
  • 11,906
  • 8
  • 54
  • 76
  • Maybe this is bad idea, but I really want THESE buttons :) – Kamil Aug 07 '13 at 09:37
  • Did you look at the `Disable Keyboard ... Window` post? In principle its a control key and you might need the `PreviewKeyDown` event and set the `PreviewKeyDownEventArgs.IsInputKey = true;` to make the key invoke other handlers like `KeyDown`. – Mike de Klerk Aug 07 '13 at 09:46
  • I tried this event. It shows arrow key codes, but volume control still does nothing. – Kamil Aug 07 '13 at 15:42
  • Then I would go for an implementation using NAudio or such. Or you could make sure its not a combination of keys. Maybe one of the control keys like CTRL or SHIFT are pressed as well? – Mike de Klerk Aug 07 '13 at 17:06