Solved

? Detecting Keyboard Errors ?

Posted on 2004-09-07
3
247 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
  • 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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

707 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now