I'm trying to read text out of google talks chat window, but I can't seem to figure out how. This is my current code:
The text length is 0. Is there a way to get the text out of the chat window?
Code:
[DllImport("user32.dll",EntryPoint="FindWindow")]
public static extern int FindWindow(string _ClassName, string _WindowName);
[DllImport("user32.dll",EntryPoint="FindWindowEx")]
public static extern int FindWindowEx(int hWnd1, int hWnd2, string lpsz1, int lpsz2);
[DllImport("user32.dll",EntryPoint="SendMessage")]
public static extern int SendMessage(int _WindowHandler, int _WM_USER, int _data, int _id);
[DllImport("user32.dll",EntryPoint="SendMessage")]
public static extern int SendMessage(int _WindowHandler, int _WM_USER, int _data, string _id);
[DllImport("User32.dll")]
public static extern bool SetForegroundWindow(int hWnd);
public void GetText()
{
int Handler = FindWindow("Chat View",null);
if (Handler > 0)
{
int Alt = FindWindowEx(Handler, 0, "AtlAxWin71", 0);
if(Alt > 0)
{
int IES = FindWindowEx(Alt, 0, "Internet Explorer_Server", 0);
if(IES > 0)
{
MessageBox.Show(SendMessage(IES, (int) WMDefs.WM_GETTEXTLENGTH, 0, 0).ToString());
SetForegroundWindow(Handler);
}
else
{
MessageBox.Show("Cannot find IES");
}
}
else
{
MessageBox.Show("Cannot find alt");
}
}
else
{
MessageBox.Show("A Google Talk chat window is not open","Error",MessageBoxButtons.OK,MessageBoxIcon.Error);
}
}
The text length is 0. Is there a way to get the text out of the chat window?