c# 如何使用MainWindowHandle获取所有窗口
看看这张图片:
这就是我获取黑框包围的窗口句柄的方法。
Process[] processes = Process.GetProcessesByName("TopazChat");
foreach (Process p in processes)
{
MessageBox.Show(p.MainWindowHandle.ToString());
List<IntPtr> test = GetChildWindows(p.MainWindowHandle);
foreach (IntPtr IGotIt in test)
{
MessageBox.Show("I got the child windows");
}
}
我的问题是:如何获取红框包围的窗口的句柄? 我的方法有问题吗?
有什么建议吗?我只是使用这种方法,因为这是我唯一熟悉的方法。
Take a look at this picture:
This is how i got the handle of the window enclosed by black box.
Process[] processes = Process.GetProcessesByName("TopazChat");
foreach (Process p in processes)
{
MessageBox.Show(p.MainWindowHandle.ToString());
List<IntPtr> test = GetChildWindows(p.MainWindowHandle);
foreach (IntPtr IGotIt in test)
{
MessageBox.Show("I got the child windows");
}
}
My question is: how to get the handle of the windows that was enclosed by red box?
and is there something wrong with my approach?
any suggestions? I just use that approach because it is the only one that is familiar to me..
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
该另一个窗口是同一进程中的另一个顶级窗口,它实现应用程序中的一个可见窗口。这是一个旧的 Delphi 7 应用程序,它实现了可见窗口层次结构之外的隐藏顶级窗口。该隐藏窗口就是您所找到的窗口,以黑色突出显示,类名为 TApplication。
如果我是你,我会调用 EnumWindows 来获取所有顶级窗口,其中包括该应用程序的可见主窗口。这将以与 GetChildWindows 方法非常相似的方式实现。
That other window is another a top-level window in the same process that implements one of the visible windows in the app. This is an old Delphi 7 app which implements a hidden top-level window that is outside the visible window hierarchy. That hidden window is the one you have found, highlighted in black, with class name TApplication.
If I were you I would p/invoke a call to EnumWindows to get all the top level windows which will include the visible main windows for that app. This would be implemented in a very similar way to your GetChildWindows method.