Solved

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

Posted on 2011-09-10
3
2,057 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 4

Expert Comment

by:Friman001
ID: 36516684
0
 

Author Comment

by:canuckconsulting
ID: 36516689
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
ID: 36516697
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

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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…
More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

617 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