在循环开头写了个readkey 回车来控制每一次重复循环,有没有办法在运行到那的时候让控制台主动转移焦点?谢谢各位了
using System.Diagnostics;
using System.Runtime.InteropServices;
[DllImport("kernel32.dll")]
static extern IntPtr GetConsoleWindow();
[DllImport("user32.dll")]
static extern bool SetForegroundWindow(IntPtr hWnd);
[DllImport("user32.dll")]
static extern bool ShowWindow(IntPtr hWnd, int nCmdShow);
//获取控制台窗体句柄
var handle = GetConsoleWindow();
while (true)
{
Console.WriteLine("提示:请输入");
//重新设置窗体显示为Normal
ShowWindow(handle, 1);
//将窗体带回前台激活
SetForegroundWindow(handle);
await Task.Delay(10 * 1000);
}
Console.ReadKey();
连标题带正文,没有一句话能看懂的
弹出,弹出什么东西
主动转移焦点,往哪转移呢
你一共就一个控制台,又不是winform多窗口工程
你要呼唤其他进程遮盖自己的cmd窗口吗