c# - distinguish between the scanner and the keyboard -


hey all. have barcode scanner connected pc working c# program.now want distinguish between scanner , keyboard 1 sending data program. can me code or advise in c#?

somebody said me in topic(but can't yet): can configure scanner send characters tell computer "hi, it's me". when see characters in input stream, know information coming barcode scanner, not user typed on keyboard. did check manual came barcode scanner? should have more information this.

if application works particular barcodes (eg same char length or ones can matched regex) possibly work out coding robot typing test. eg:

vb.net:

private sw stopwatch private sub firstcharacterentered()     sw.start() end sub private sub txt_textchanged(byval sender system.object, byval e system.eventargs) handles txt.textchanged     if txt.length = 0 firstcharacterentered()     if txt.length = barcodeseriallength or new regularexpressions.regex("your pattern").ismatch(txt.text)         sw.stop()         if sw.elapsedmilliseconds < timeahumanwouldtaketotype             'input barcode scanner         end if         end if end sub 

c#:

private stopwatch sw; private void firstcharacterentered() {     sw.start(); } private void txt_textchanged(system.object sender, system.eventargs e) {     if (txt.length == 0)         firstcharacterentered();     if (txt.length == barcodeseriallength | new regularexpressions.regex("your pattern").ismatch(txt.text)) {         sw.stop();         if (sw.elapsedmilliseconds < timeahumanwouldtaketotype) {             //input barcode scanner         }     } } 

Comments

Popular posts from this blog

php - What is the difference between $_SERVER['PATH_INFO'] and $_SERVER['ORIG_PATH_INFO']? -

fortran - Function return type mismatch -

queue - mq_receive: message too long -