Quote 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:
  1. 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
  2. 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
  3. Private Const WM_CHAR As Long = &H102
  4.  
  5. Private Sub Command1_Click()
  6.  
  7.     Dim h As Long
  8.    
  9.     h = FindWindowEx(0, 0, "ConsoleWindowClass", vbNullString)
  10.     If h Then PostMessage h, WM_CHAR, Asc("a"), 0
  11.  
  12. End Sub