我想通过文本框句柄检查其他进程文本框控件是否是其他进程主窗口中的活动控件。
代码应如下所示:
Dim TheMainWinDowHandle As IntPtr = Process.GetProcessesByName("proccessName")(0).MainWindowHandle
If TheMainWinDowHandle <> IntPtr.Zero Then
Dim TextBoxHandle As IntPtr = FindWindowEx(TheMainWinDowHandle, 0, "Edit", "TextBox Inner Text")
If TextBoxHandle <> IntPtr.Zero Then
Dim TheActiveHandleInTheMainWindow As IntPtr = GetActiveHandleFrom(TheMainWinDowHandle) 'TheActiveHandleInTheMainWindow = The Focused Control Handle Of "TheMainWinDow".
If TheActiveHandleInTheMainWindow = TextBoxHandle Then
MsgBox("The TextBox Is onFocus")
Else
MsgBox("The TextBox Is Not In Focus.")
End If
End If
End If
我该怎么做(c#/vb.net)?