ここで私の回答のコードの一部を使用できます: Correct way (in .NET) to switch the focus to another application、 set active window 宣言を set foreground window function に変更するだけです。 ShowWindow 関数。
Visual Basic 6 の定義
Declare Function SetForegroundWindow Lib "user32.dll" (ByVal hwnd As Long) As Long
Visual Basic .NET 定義
Declare Function SetForegroundWindow Lib "user32.dll" (ByVal hwnd As Integer) As Integer
C# 定義
[DllImport("user32.dll")] public static extern int SetForegroundWindow(int hwnd)
あなたの目標がuser32.dllインポートを使用することではない場合、あなたのアプリケーションはターゲットアプリケーションにアクセスできないため、ウィンドウを使用する必要があるため、かなり面倒です。
または、ある種のプロセス間通信システム (キーワード: .net リモーティング) を使用して、フォーカス スニペットをターゲット アプリケーションにコーディングし、アプリケーションからフォーカス メッセージを 2 番目のアプリに送信するだけです。