Solved

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

Posted on 2011-09-10
3
1,994 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
transition to visual .net from vb6 5 62
linq, c# 8 33
Header Font Size in Grid View 6 25
ASP.NET data base connection 35 37
This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
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…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

749 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