Alex Rivera | Logout

How do I tell if keyboard input is coming from a barcode scanner?

Asked 2011-04-11T11:43:32.983
18

On one computer I have both a regular keyboard and a barcode scanner which emulates a keyboard. When my app gets keyboard input, how can I determine whether that input is coming from the barcode scanner or the real keyboard?

Edit
Report

2 Answers

4

Take a look at Microsoft's MultiPoint SDK

(edit: this answer is no longer applicable now that the question has been clarified. i'm leaving it here for others to discover though)

answered 2011-04-11T11:55:07.143
0

Try:

Dim PreviousKeyPressTime As DateTime = Nothing

Private Sub TextBox1_KeyDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles TextBox1.KeyDown

    If e.KeyCode = Keys.Enter Then
        PreviousKeyPressTime = Nothing
        TextBox1.Text = String.Empty
    Else
        If PreviousKeyPressTime = Nothing Then
            PreviousKeyPressTime = DateTime.Now
        End If
        Dim startTime As DateTime = Now
        Dim runLength As Global.System.TimeSpan = startTime.Subtract(CType(Me.PreviousKeyPressTime, DateTime))
        Dim millisecs As Integer = runLength.Milliseconds
        Dim secs As Integer = runLength.Seconds
        Dim TotalMiliSecs As Integer = ((secs * 1000) + millisecs)

        lblDiff.Text = TotalMiliSecs

        If TotalMiliSecs <= 50 Then
            lblMsg.Text = String.Empty
        Else
            lblMsg.Text = "keyboard Input not Allow"
        End If
        PreviousKeyPressTime = DateTime.Now
    End If
End Sub

Source : http://itlearnerinsect.blogspot.com/

answered 2012-01-24T15:31:44.253

Your Answer