3
根據http://msdn.microsoft.com/en-us/library/ms633500(v=vs.85).aspx我定義了FindWindowEx函數。C#根據名稱和序號使用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。
IntPtr hWndParent = new IntPtr(2032496); // providing parent window handle
IntPtr hWndButton = FindWindowEx(hWndParent, IntPtr.Zero, "Button", string.Empty);
如何獲得第二,第三或父窗口裏面的「按鈕」控件的什麼把柄?事實是,按鈕標題可能會有所不同,所以我無法直接通過名稱來定義第四個參數。
請重新表述您的問題對我們理解。 – 2011-04-15 07:59:33
爲什麼不使用UIAutomation命名空間? – 2012-07-22 16:57:44
我的解決方案可以用於非託管C++程序以及代碼片段是完全相同的:)這是爲了挖掘/黑客攻擊,而不是用於測試目的。不喜歡研究中的任何隨時可用的自動化。 – 84RR1573R 2012-07-22 21:55:14