2

I have a Windows Media Center remote that windows recognizes as a keyboard. When I run a multi-monitor setup with Windows Media Center playing a video on one screen, the remote's input is directed to the active window along with the regular keyboard. So when I'm doing something with the other screen, Windows Media Center doesn't respond to the remote. So I thought I'd write a simple low level keyboard hook that traps all key events, determines which presses came from the remote, and redirects those to the open Media Center window.

The only problem is, I can't seem to find anything in the Windows API for this. Is there any way to determine the source of a keypress short of writing a driver?

jnm2
  • 7,960
  • 5
  • 61
  • 99
  • how about hooking all the key events, and checking the keycodes received from the remote manually so you implement in the solution? Another possible way is checking it true the remote connection port to the PC. – Chibueze Opata Apr 14 '12 at 03:54
  • Most of the keycodes are the same as my other keyboard. Also it's plugged into a USB hub. How could I intercept it without a driver? – jnm2 Apr 14 '12 at 15:27
  • 1
    I actually thought it was a WiFi remote, still an alternative approach is by handling Raw Input. – Chibueze Opata Apr 15 '12 at 02:50

1 Answers1

2

You can handle raw input in order to process keystrokes and identify which device they come from. This article explains how.

Chibueze Opata
  • 9,856
  • 7
  • 42
  • 65
  • Hmm, tested now and works on my PC, Anyway, if you encounter any problems feel free to ask... good luck. – Chibueze Opata Apr 15 '12 at 23:33
  • Ohhh, that makes sense. I'm on x64 Windows and the sample is set to AnyCpu. The RAWINPUT offsets are off. I'll just compile to x86. – jnm2 Apr 16 '12 at 00:21
  • Also, I can't block raw input. I'll have to have an additional keyboard hook that blocks all input. – jnm2 Apr 16 '12 at 00:24
  • You just need one hook to block all inputs, You should hook the [BlockInput win32](http://msdn.microsoft.com/en-us/library/windows/desktop/ms646290(v=vs.85).aspx) api function. – Chibueze Opata Apr 16 '12 at 00:55