【发布时间】:2011-08-06 02:20:13
【问题描述】:
根据http://msdn.microsoft.com/en-us/library/ms633500(v=vs.85).aspx我定义了FindWindowEx函数。
using System.Runtime.InteropServices;
[DllImport("user32.dll", CharSet=CharSet.Unicode)]
static extern IntPtr FindWindowEx(IntPtr parentHandle, IntPtr childAfter, string lclassName, string windowTitle);
现在我可以找到将 childAfter 设置为 IntPtr.Zero 的“Button”控件的 first 句柄(从 Spy++ 获取名称)。
IntPtr hWndParent = new IntPtr(2032496); // providing parent window handle
IntPtr hWndButton = FindWindowEx(hWndParent, IntPtr.Zero, "Button", string.Empty);
如何在该父窗口中获取 second、third 或“Button”控件的任何句柄?事实上,按钮标题可能会有所不同,因此我无法通过定义第四个参数的名称直接找到它们。
【问题讨论】:
-
请重新表述您的问题以便我们理解。
-
为什么不使用 UIAutomation 命名空间?
-
我的解决方案可用于非托管 C++ 程序,sn-p 也是如此 :) 这是用于挖掘/黑客攻击,而不是用于测试目的。不喜欢研究中的任何即用型自动化。
标签: c# winapi visual-c++ handle spy++