Solved

? Detecting Keyboard Errors ?

Posted on 2004-09-07
3
257 Views
Last Modified: 2010-04-23
i am useing VB.NET, and working within a windows form.

in my form i am useing SendKeys.SendWait(var)
sometimes the focus of my target application changes, and when i send the key stroke i get a keyboard error, ie. a "beep" sound from the system.

is there anyway to detect this error? this would be done so i can resend the key that resulted in an error.

thanks.
0
Comment
Question by:frosty5656
[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
  • 2
3 Comments
 
LVL 27

Accepted Solution

by:
planocz earned 109 total points
ID: 12005585
Here is a function that you can use to catch the key strokes before it gets to the other Keypress events...

SAMPLE:

   Protected Overrides Function ProcessCmdKey(ByRef msg As Message, ByVal keyData As Keys) As Boolean
        Const WM_KEYDOWN As Integer = &H100
        Const WM_SYSKEYDOWN As Integer = &H104

        If ((msg.Msg = WM_KEYDOWN) Or (msg.Msg = WM_SYSKEYDOWN)) Then
            Select Case (keyData)
                Case Keys.A
                    TextBox1.Text = "Key A"
                Case Keys.Left
                   TextBox1.Text = "Key Left"
                Case Keys.Down
                       TextBox1.Text = "Key Down"
                Case Keys.Up
                    Me.Parent.Text = "Up Arrow Captured"
                Case Keys.Tab
                    Me.Parent.Text = "Tab Key Captured"
                Case (Keys.Control Or Keys.M)
                    Me.Parent.Text = "<CTRL> + M Captured"
                Case (Keys.Alt Or Keys.Z)
                    Me.Parent.Text = "<ALT> + Z Captured"
            End Select
        End If

        Return MyBase.ProcessCmdKey(msg, keyData)
    End Function
0
 

Author Comment

by:frosty5656
ID: 12013213
thanks for the reply.

i don't understand how capturing what key is being pressed helps my problem? will this function return a value when a keyboard error occurs? sorry i'm fairly new to vb.net, could you explain your solution a bit more?

thanks.
0
 
LVL 27

Expert Comment

by:planocz
ID: 12015321
This will pickup any key that you are using. If you have to press a special key this will pick it up.
There is no need to look just for errors.
0

Featured Post

Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

Question has a verified solution.

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

A while ago, I was working on a Windows Forms application and I needed a special label control with reflection (glass) effect to show some titles in a stylish way. I've always enjoyed working with graphics, but it's never too clever to re-invent …
Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
Suggested Courses

626 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