我有一個主窗口,它有一個TEdit和一個TButton,我需要這些句柄。他們都在TPanel內。我的代碼到目前爲止是無法從TPanel獲得TEdit句柄
public void SendPacket(string packet)
{
IntPtr hWnd = Window.FindWindow(null, "AlissaAnalyzer");
IntPtr panel = Window.FindWindowEx(hWnd, IntPtr.Zero, "TPanel", "");
IntPtr edithWnd = Window.FindWindowEx(panel, IntPtr.Zero, "TEdit", "");
IntPtr buttonhWnd = Window.FindWindowEx(panel, IntPtr.Zero, "TButton", "");
//Do stuff with handles
}
這給了我TPanel和TButton,但爲TEdit的手柄。我不知道爲什麼,這並不工作,因爲它遵循間諜++給我的結構:
有我丟失的東西嗎?我需要一種不同的方法來獲得TEdit的句柄嗎?我使用FindWindowEx錯誤嗎?
如果你想從.NET做UI自動化,White項目可能會簡化你的工作:http://white.codeplex.com/ – 2012-01-02 03:41:07
我不認爲TEdit的父窗口是面板...嘗試IntPtr edithWnd = Window.FindWindowEx(hWnd,IntPtr.Zero,「TEdit」,「」); – ComputerSaysNo 2012-01-02 04:34:04
P.S.我也注意到,你在截圖中有一個TMemo但不是TEdit,是否可以用備忘錄代替TEdit字段? – ComputerSaysNo 2012-01-02 04:38:02