查找 GoogleTalk 的状态
我正在尝试创建一个程序来显示 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());
谢谢。
I am trying to create a program which will show me the status of my Gtalk (online/offline).
I can find the Status View 2 class, but how can I find the text within it.
Here's my code.
API decleration :
[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);
Code that calls 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());
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我自己找到了解决方案。感谢 abazabam。
如果你看图,有一个面板,其类名为“ #32770”,窗口标题是“登录对话框”。
当用户离线时,该面板可见,而当用户上线时,该面板不可见。
所以主要逻辑是检测面板的可见性。
您可以使用 Spy++ 查找类名。
API 声明:
代码:
无论如何,感谢您阅读我的问题。
I found a solution my self. Thanks to abazabam.
If you look at the figure, there is a panel whose class name is "#32770" and Window Caption is "Sign In Dialogue"
When the user is offline then this panel is visible, and when the user goes online the panel is not visible.
So the main logic is to detect the visibility of the panel.
You can use Spy++ to find the class name.
API decleration :
Code :
Anyways thanks for reading my problem.