Solved

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

Posted on 2011-09-10
3
2,014 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

Forrester Webinar: xMatters Delivers 261% ROI

Guest speaker Dean Davison, Forrester Principal Consultant, explains how a Fortune 500 communication company using xMatters found these results: Achieved a 261% ROI, Experienced $753,280 in net present value benefits over 3 years and Reduced MTTR by 91% for tier 1 incidents.

Question has a verified solution.

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

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…
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…
This video shows how to use Hyena, from SystemTools Software, to update 100 user accounts from an external text file. View in 1080p for best video quality.

751 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