Is it possible to swallow a key in Raw Input?

前端 未结 3 1426
故里飘歌
故里飘歌 2021-01-13 09:24

I am using the Raw Input API because I need to be able to respond to keys from different USB HID devices differently, even if it is the same key.

My

3条回答
  •  心在旅途
    2021-01-13 10:08

    As written above, there is no direct possibility, but you can make it by combining low-level keyboard hooks.

    In my case, I need to catch code from barcode scanner so that's only digits and ENTER.

    My solution is that RawInput captures all keys only from barcode scanner device, and keyboard hookup captures only digits 0-9 and ENTER and does not return it at all. Then, inside the code, I'm deciding whether key needs to be returned or not by:

    SendKeys.SendWait("{ENTER}");
    

提交回复
热议问题