I am trying to send text to an external running program using sendkeys. The code I have works, but if I insert a breakpoint and step through the code, it freezes. It freezes at "SendKeys.Send("^s")". Could someone please tell me why or offer me some suggestions?
Thanks
Ron
Module Module1
Declare Auto Function FindWindow Lib "user32" (ByVal lpClassName As String, _
ByVal lpWindowName As String) As IntPtr
Declare Auto Function SetActiveWindow Lib "user32" (ByVal hwnd As IntPtr) As Integer
Declare Auto Function GetWindowText Lib "user32" _
(ByVal hWnd As System.IntPtr, _
ByVal lpString As System.Text.StringBuilder, _
ByVal cch As Integer) As IntPtr
Declare Auto Function FindWindowEx Lib "user32" _
(ByVal hWnd1 As IntPtr, ByVal hWnd2 As IntPtr, _
ByVal lpsz1 As String, ByVal lpsz2 As String) As IntPtr
Sub Chat()
' Get the target's window handle.
Dim targetWnd As IntPtr = FindWindow("New Deal Window", vbNullString)
' Create a buffer of 256 characters
Dim Caption As New System.Text.StringBuilder(256)
Dim chatstr As New System.Text.StringBuilder(256)
Dim chatText As String = Form1.TextBoxExt1.Text
SetActiveWindow(targetWnd)
SendKeys.Send("^s")
SendKeys.Send(chatText)
SendKeys.Send("{ENTER}")
End Sub
End Module