他のプロセスのテキスト ボックス コントロールが、テキスト ボックス ハンドルによって他のプロセスのメイン ウィンドウでアクティブなコントロールであるかどうかを確認したい。
コードは次のようになります。
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)?