I have two devices(KeyBoard and BarCodeScanner) and 2 textboxes(text box 1 and text box 2).
Now I want to restrict user that he can only use keyboard in text box 1 and barcodescanner in text box 2.
How is this possible in C#?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You should have a look at this: Read data from Bar Code Scanner in .net (C#) windows application!
So your scanner might send special characters to help you identify it the input was from a scanner, or maybe it provides you with an additional library you could use to detect such events.
Let’s suppose thought the scanner acts identically to a keyboard without any special characters to help you know it was from a scanner and without any additional library from the manufacturer site you could use.
Then what you could use is: measure the typing speed in the KeyDown event of the second textbox.
I suspect the scanner enters the code instantly so you would have a huge typing speed measured.
Then if the typing speed is greater than a threshold ( E.g. for humans the world speed record is somewhere around 1000 characters per minute) then you delete the text that was entered.
It’s hacky, but I’ve got no better idea.