我正在尝试创建一个程序来显示我的 Gtalk 的状态(在线/离线)。
我可以找到 Status View 2 类,但如何找到其中的文本。
这是我的代码。
API 声明:
[DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Auto)]
private static extern IntPtr FindWindowEx(IntPtr parentHandle, IntPtr childAfter, string lclassName, string windowTitle);
[DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Auto)]
private static extern IntPtr FindWindow(string lpClassName, string lpWindowName);
调用 Api 的代码:
IntPtr hwnd = IntPtr.Zero;
hwnd = FindWindowEx(hwnd, IntPtr.Zero, "Google Talk - Google Xmpp Client GUI Window", "Google Talk");
hwnd = FindWindowEx(hwnd, IntPtr.Zero, "Main View", "@main");
hwnd = FindWindowEx(hwnd, IntPtr.Zero, "Status View 2", "Status Box");
hwnd = FindWindowEx(hwnd, IntPtr.Zero, "RichEdit20W", "String.Empty");
MessageBox.Show(hwnd.ToString());
谢谢。