创建函数“查找窗口..."C#中的间谍++ [英] create the function "find window..." of spy++ in C#

查看:36
本文介绍了创建函数“查找窗口..."C#中的间谍++的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在 C# 中创建与 spy++ 相同的函数查找窗口...".我已经尝试过 WINAPI 的这个功能:

I want to create the same function "Find windows..." of spy++ in C#. I have try with this function of the WINAPI:

HWND WINAPI WindowFromPoint(__in  POINT Point);

http://msdn.microsoft.com/en-US/library/ms633558.aspx但我不是来获取所有元素的,因为它们被禁用或隐藏.

http://msdn.microsoft.com/en-US/library/ms633558.aspx But i don't arrive to get all element with that, because they are disabled or hidden.

例如,在程序员模式下使用 windows 7 计算器,我无法获得A B C D E F"使用我的程序,如果它们被禁用,那么 spy++ 可以得到它.

For example with the window 7 calculator in Programmer mode, i cannot get the "A B C D E F" with my program if they are disable then spy++ can get it.

我试过这个,但它不起作用:

I have try this but it don't working:

[DllImport("user32.dll")]
public static extern ulong GetClassLongPtr(IntPtr hWnd, int nIndex);

[DllImport("user32.dll")]
public static extern IntPtr ChildWindowFromPointEx(IntPtr hWndParent, Win32Point pt, uint uFlags);

IntPtr hWnd = WindowFromPoint(myPoint);
hWnd= ChildWindowFromPointEx(hWnd , myPoint, 0x0000);

myPoint 是我鼠标的位置.

myPoint is the position of my mouse.

我不熟悉 WINAPI,我认为您的解释是对我缺乏了解.有可能有一个 ChildWindowFromPointEx 函数的小例子,或者知道我的代码不起作用吗?感谢您的回答

I don't familiar with the WINAPI and i imagine with your explanation that is a lack of understanding of me. It's possible to have a little example of ChildWindowFromPointEx function or know what my code don't working? thanx for your answer

我尝试创建循环,但似乎句柄在另一个句柄下,但不是句柄的子句,当键a b c d e f"被禁用时,循环总是发送相同的句柄并且没有想要的子句.你有别的想法吗?

I have try to create the loop but, it seems the handle is under the other handle but is not children of the handle, the loop send alway the same handle and no the desire child when the key " a b c d e f" is disabled. Do you have another idea?

推荐答案

WindowFromPoint 返回一个窗口句柄.由于您正在处理禁用/隐藏的窗口,因此您需要使用 ChildWindowFromPointEx,传入 hwndParent 作为您从 WindowFromPoint 获得的任何句柄.

WindowFromPoint returns a window handle. Since you are dealing with disabled/hidden windows, you would want to use ChildWindowFromPointEx, passing in hwndParent as whatever handle you obtained from WindowFromPoint.

您可能会发现以下文章很有帮助:http://blogs.msdn.com/b/oldnewthing/archive/2010/12/30/10110077.aspx

You might find the following article helpful: http://blogs.msdn.com/b/oldnewthing/archive/2010/12/30/10110077.aspx

关于您添加的代码,ChildWindowFromPointEx 获取客户端坐标,而您拥有的鼠标位置坐标是屏幕坐标.您可以使用 ScreenToClient 进行转换.

In regards to the code you added, ChildWindowFromPointEx takes client coordinates, whereas the mouse position coordinates you have are screen coordinates. You can do the conversion with ScreenToClient.

注意:这是 WinAPI 做事的方式.我不知道 C# 是否提供或提供哪些 API.

Note: This is the WinAPI way to do things. I have no idea whether or what APIs C# supplies.

这篇关于创建函数“查找窗口..."C#中的间谍++的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆