Solved

Detect input source (keyboard or USB device) on Windows 7 .Net Windows Application

Posted on 2011-09-10
3
1,850 Views
Last Modified: 2013-12-17
I have a .Net 4 Windows Forms project with Visual Studio 2010 using c#.  This is running on Windows 7 x64 laptop.

I need to determine if input has originated from the laptop's keyboard or from barcode scanner attached by USB.  Can I do this?
0
Comment
Question by:canuckconsulting
3 Comments
 
LVL 4

Expert Comment

by:Friman001
Comment Utility
0
 

Author Comment

by:canuckconsulting
Comment Utility
I need to know if the input has come from the scanner though as I treat it different to data from keyboard.  Ultimately I want any scanned data to result in a search no matter what screen or control a user is on.
0
 
LVL 40

Accepted Solution

by:
Jacques Bourgeois (James Burger) earned 500 total points
Comment Utility
It depends on how your scanner returns the data, but since you seem to have problem identifying between the scanner and the keyboard, the scanner probably returns the data throught the KeyPress event. Isn't it?

If so, I would be surprise that it would also trigger the KeyDow event. You could set a form level boolean variable to True in KeyDown and check for it in the KeyPress. If it is True, that means that the data is coming from the keyboard.

Do not forget to reset it to False at the end of the KeyPress, in order to be able to properly detect the provenance of the next character.
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

In my previous two articles we discussed Binary Serialization (http://www.experts-exchange.com/A_4362.html) and XML Serialization (http://www.experts-exchange.com/A_4425.html). In this article we will try to know more about SOAP (Simple Object Acces…
Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now