We take pride in your success. We let our positivity drive us, day in and out. Talk to us at Mindfire to know us more.

Software Technology Tips

Sometimes we need to simulate the keyboard press events programmatically in our application to handle system defined messages and make the application more user friendly.

To simulate the keyboard press events for tabbing and Enter key press we can use following code snippets:

 

[Start VB.Net code]

 

Imports System.Threading

 

'Declare a thread object to do the keyboard press events.
Dim thrd as Thread

 

Private Sub btnEmail_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) _
                               Handles btnEmail.Click

        Me.Close()
        Application.DoEvents()

        thrd = New Thread(AddressOf ThreadTask)
        thrd.IsBackground = True
        thrd.Start()

End Sub

 

Private Sub ThreadTask()

        Thread.Sleep(100)
        SendKeys.SendWait("{TAB}")
        Thread.Sleep(10)
        SendKeys.SendWait("{ENTER}")
       
End Sub

 

[End VB.Net code]


Related Tags:

Keyboard press events, VB.NET

Author: Shibani Shubhadarshini

top

VB.NET

Let us Connect!

privacy

copyright (c) Mindfire Solutions 2007-2012. Login