0

Currently I have a Win32 desktop program written in C++ that uses the Raw HID Input API (a message loop observing WM_INPUT messages) to read key events and also get a handle to the specific keyboard that produced the event. I need this information to change the behavior depending on the keyboard when I use multiple keyboards.

Now because developing a nice Win32 GUI seems a pain to me, I'd like to use a UWP UI. I tried KeyRoutedEventArgs.DeviceId but this is always an empty string (""). Maybe this is because it is only supported on Xbox?

The alternative would be to use the Raw Input API again, but the first problem I'm running into then is: can I even obtain window messages from a UWP window? And if so: is it possible to combine this with the Raw Input API to receive WM_INPUT messages?

To be clear: I don't need the program to be on the Windows Store or anything, I would just like to have a nice UI. But maybe (probably?) this is not possible in this way :/

Something which I just thought of is to try to globally listen for events by using RIDEV_INPUTSINK when the UWP app window is focused, but this is a mild hack and I hope there is a better and easier way like the DeviceId property would be.

SWdV
  • 1,715
  • 1
  • 15
  • 36

1 Answers1

0

Great question, I'm afraid you could not distinguish multiple keyboards when typing in UWP app. I found you have used win32 api to detect the keyboards successfully, with help of desktop-bridge, you could use the same way in UWP platform . In other words, you could make desktop extension for uwp app, and send the different keyboard info to main uwp app with AppService. And Stefan has a blog that explain how to use desktop extension to detect global hot key. You could google Global hotkey registration in UWP for the detail.

Nico Zhu
  • 32,367
  • 2
  • 15
  • 36