0
我不明白为什么它不起作用?SetForegroundWindow不会激活我的窗口
static void ActivateApp(string processName)
{
Process[] p = Process.GetProcessesByName(processName);
// Activate the first application we find with this name
if (p.Any()) SetForegroundWindow(p[0].MainWindowHandle);
else
{
Console.WriteLine("Something wrong");
}
}
[STAThread]
static void Main(string[] args)
{
ActivateApp("Acrobat.exe");
}
输出:
有些事情不对
但我敢肯定,Acrobat.exe存在。
将'Acrobat.exe'改为'Acrobat'。 –
你的意思是不工作?例外?在控制台中出现“错误”的内容?请详细说明。 – jordanhill123
谢谢@ByteBlast,jordanhill123,是有“蹊跷”,现在它走了,但我仍然窗口会显示不出来,也许我错了,但这种方法应该是把选择的过程Windows来所有其他Windows的顶部,对吧? – Ydhem