
Originally Posted by
RobDog888
So SendMessage will only work if you create the pipe first? I know it doesnt work directly by getting the CMD window handles.
You shouldn't have to bring pipes into it
The following works for me
VB Code:
Private Declare Function PostMessage Lib "user32.dll" Alias "PostMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Private Declare Function FindWindowEx Lib "user32.dll" Alias "FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long
Private Const WM_CHAR As Long = &H102
Private Sub Command1_Click()
Dim h As Long
h = FindWindowEx(0, 0, "ConsoleWindowClass", vbNullString)
If h Then PostMessage h, WM_CHAR, Asc("a"), 0
End Sub