我正在尝试制作一个类似地震样式的下拉HUD控制台应用程序。我可以让它显示和隐藏窗口,但我无法在显示后将其设置为活动窗口。我正在使用Win API调用来显示和隐藏窗口。我已经尝试了SetForegroundWindow(IntPtr hWnd)和SetFocus(IntPtr hWnd),但都没有成功。有人有什么想法吗?
http://pastebin.com/DgtJJGiv
public void ShowApp()
{
IntPtr h = FindWindow(null, "C:\\Windows\\system32\\cmd.exe");
ShowWindow(h, SW_SHOW);
//EnableWindow(h, true);
isHidden = false;
// set focus to console window
SetForegroundWindow(h);
System.Diagnostics.Debug.WriteLine(h);
}