I am using SendKeys.Send("{HOME}")
in a MaskedTextBox
to bring the cursor to the beginning of the textbox when the text is empty.
When I try to close the project the application freezes if it doesn't have focus.
How do I put this application in focus before I call SendKeys
?
Public Class Form1
Private Sub MaskedTextBox1_GotFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles MaskedTextBox1.GotFocus
Try
SendKeys.Send("{HOME}")
Catch ex As InvalidOperationException
' Do nothing
End Try
End Sub
End Class
After that, it should give focus to the previous application and close.