Link to home
Start Free TrialLog in
Avatar of mahmuod
mahmuod

asked on

how to detect type device scanner or keyboard ?

hi
i want design form these form accept number for symbols scanners barcode only   if any one   type from normal keyboard  or copy past number not accept
how to detect type device scanner or keyboard  ?
  User generated image
SOLUTION
Avatar of Bembi
Bembi
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of mahmuod
mahmuod

ASKER

ok but how to make it by c#
Check the events that are triggered when the scanner sends it information to the application. This can change depending on the scanner.

If the scanner sends only a KeyPress or a TextChanged and no KeyDown, then simply set e.SuppressKeyPress=True in the KeyDown event of the control. This will prevent a key from the keyboard from going to the control.

If this does not work with you scanner, you might want to use a timer to calculate the time it takes to type fill the control. Manual entry is usually a lot slower than the scanner, so with some tests, you should be able to come with a duration that will tell you if the scanner or the keyboard is sending the data. If the timing between the first character and the second one is too long, delete the first character and display a warning message.
Avatar of mahmuod

ASKER

The scanner action same keyboard . Can not select  type keyboard or scanner
But if the code only one deget can not calculate time
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial