I would very much like an answer to this question.
It looks as though it should work with a windows handle, however it seems to only work when I supply a control handle.
Anyone able to provide a definitive answer to this?
Thanks
For reference, the code in question:
Public Class Form1
Private Declare Function FindWindow Lib "user32.dll" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Integer
Private Declare Function FindWindowEx Lib "user32.dll" Alias "FindWindowExA" (ByVal hWnd1 As Integer, ByVal hWnd2 As Integer, ByVal lpsz1 As String, ByVal lpsz2 As String) As Integer
Private Declare Ansi Function SendMessage Lib "user32.dll" Alias "SendMessageA" (ByVal hwnd As Integer, ByVal wMsg As Integer, ByVal wParam As Integer, ByVal lParam As String) As Integer
Private Const WM_CHAR = &H102
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim windowHandle As Integer = FindWindow(vbNullString, "Untitled - NotePad") '/// assuming you have notepad open.
Dim controlHandle As Integer = FindWindowEx(windowHandle, 0, "Edit", vbNullString)
SendMessage(windowHandle, WM_CHAR, Keys.B, 0) '<-- Doesn't work
SendMessage(controlHandle, WM_CHAR, Keys.C, 0) '<-- Works
End Sub
End Class