我一直在网上寻找答案,让程序到达前台。我一直在通过发送带有SendKeys的alt-tab键击来实现这种贫民窟。我试过这个并没有用,
private void execute()
{
setApp("League of Legends.exe");
Thread.Sleep(1500);
}
[DllImport("user32.dll")]
static extern bool SetForegroundWindow(IntPtr hWnd);
private static void setApp(String filename)
{
Process[] SameProcesses = Process.GetProcessesByName(filename);
Process SameProcess = SameProcesses[0];
if (SameProcess.Equals(null))
{
System.Windows.Forms.MessageBox.Show("No process");
}
else
{
SetForegroundWindow(SameProcess.MainWindowHandle);
}
}