Block keyboard input and only allow bar code reader input

0

I have the following problem, I want to restrict the entry of data to a textbox, which only allows the data to enter through a barcode scanner and prevent the user from typing the code, since to type the code has to enter as another type of user. What he tried was the following

 if(textBox1.Text.Length > 1)
            {

            }
            else
            {
                textBox1.Clear();
                MessageBox.Show("No puedes ingresar el codigo de manera manual");

            }

but apparently the code also affects what the scanner is. I want to know if there is any way to achieve it

    
asked by R. Nuñez 10.08.2018 в 18:15
source

1 answer

0

If a bar code reader is a keyboard, you could prevent it by intercepting its name with an HID library for .NET if the device is USB. The bad thing is that you should learn well how to use it.

This library helped me, but more for USB storage:

link

and its installer in Package Manager Console:

PM > Install-Package hidlibrary

    
answered by 10.08.2018 в 20:13