This is a simplified version of what I am trying to implement to grab text from a mIRC chat window:
[DllImport("user32.dll", EntryPoint = "SendMessage")]
private static extern int SendMessage(IntPtr hwnd, int msg, int wParam, StringBuilder sb);
public const int WM_GETTEXT = 0x000D;
IntPtr mainHandle = FindWindow("mIRC", null);
IntPtr serverHandle = FindWindowEx(mainHandle, new IntPtr(0), "MDIClient", null);
IntPtr chanHandle = FindWindowEx(serverHandle, new IntPtr(0), "mIRC_Channel", null);
IntPtr staticHandle = FindWindowEx(chanHandle, new IntPtr(0), "Static", null);
int length = 50000;
StringBuilder sb = new StringBuilder(length + 1);
SendMessage(staticHandle, WM_GETTEXT, length + 1, sb);
textBox1.Text = sb.ToString();
However, this is not returning anything. It works for other windows, just not the Static window. Why? And please off any suggestions you may have for how I can read text from a mIRC window?