Solved

? Detecting Keyboard Errors ?

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

Independent Software Vendors: 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

This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Come and listen to Percona CEO Peter Zaitsev discuss what’s new in Percona open source software, including Percona Server for MySQL (https://www.percona.com/software/mysql-database/percona-server) and MongoDB (https://www.percona.com/software/mongo-…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

734 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