获取没有标题的窗口的句柄.. (C#)
我们怎样才能得到一个没有标题的窗口的句柄呢?有没有一种方法可以枚举桌面上的所有窗口并过滤没有标题的窗口(在我的例子中,只有一个)并获取它的句柄..或者通过指定其他属性,例如具有标题的窗口特定按钮或列表框等...
How can we get the handle of a window that doesn't have a title? Is there a way to enumerate all the windows on desktop and filter the window that don't have a title (in my case, there is only one) and getting the handle of it.. or by specifying other attributes like a window that has a specific button or listbox etc...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
这应该可以做到:
This should do it:
看一下 EnumChildWindows 函数。
我认为如果你将主窗口(即桌面)的指针传递给这个函数,你将能够获得所有窗口及其子窗口的列表。
与 FindWindow 结合使用,一旦找到所需的子控件,就应该可以获得所需窗口的句柄。
Take a look at the EnumChildWindows function.
I think that if you pass in the pointer of the main window (i.e. desktop) to this function, you will be able to get a list of all windows and their child windows.
In combination with FindWindow it should be possible to get the handle to the window you want once you locate an expected child control.
像这样的东西应该可以工作,未经测试
Something like this should work, not tested
http://msdn.microsoft.com/en-us /library/ms633558(VS.85).aspx
WindowFromPoint 返回一个句柄,如果光标下方没有窗口,则返回 null。可以使用它吗,或者您是否正在尝试使该过程自动化?
http://msdn.microsoft.com/en-us/library/ms633558(VS.85).aspx
WindowFromPoint returns a handle, or null if no window is underneath your cursor. Could this be used, or are you trying to automate the process?
在这里您可以找到一个库来处理托管代码中的 Windows API 内容。
下载 dll 并在您的项目中引用它,然后就可以很容易地
获取您想要的任何窗口的任何信息;
Here you can find a library to deal with windows API stuff in managed code.
Download the dll and reference it in your project and from there on it's very easy to
get any information on any window you want;