Question

I would like to use the RawInput API for a barcode reader, but I do not want the barcode reader's output to be processed by Windows after I am done with it.

The reason I would like to use the RawInput API is that it allows me to discern between regular keyboard input and barcode reader input.

I know that this can be done using a low level keyboard procedure, but that does not provide any information on the device responsible for the event.

Was it helpful?

Solution

As per the following question it appears not to be possible to use the RawInput API to swallow key input: Is it possible to swallow a key in Raw Input?.

One other possibility would be to set focus to my application from the RawInput API and handle the input in the main form's KeyPress event. This way I can suppress the keys by settings the e.Handled state to true.

Another alternative would be to use both a global hook and the RawInput API, but this would require two separate processes as the RawInput API unhooks any global hook within the same process.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top