您可以使用我的答案中的一些代碼:Correct way (in .NET) to switch the focus to another application,只需將設置的活動窗口聲明更改爲設置的前景窗口函數,也可以嘗試對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中進口,那麼你的非常麻煩,因爲您的應用程序無法訪問目標應用程序以實現它成焦點,你將需要使用Windows。
或者你可以使用某種進程間通信系統(關鍵詞:.NET遠程處理)和代碼的焦點片段注入目標applciation,然後從你的應用程序只發送焦點消息給你的第二個應用
讓我回到與SwitchToThisWindow相同的地方。但是當窗口最小化時它不起作用。 – 2010-02-23 18:52:44