本文介绍了有没有一种方法可以使控制台窗口以编程方式在任务栏中闪烁的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 基本上,我制作了控制台应用程序,执行一些需要几分钟的任务。我想让它在任务栏中闪烁,以便在完成任务时通知我。Basically I made console app that performs some task that takes a few minutes. I'd like to have it flash in the taskbar to let me know when it's done doing its thing.推荐答案使用回答@ Zack发布了和另一个找到控制台应用程序句柄的 我想出了这一点,并且效果很好。Using the answer that @Zack posted and another one to find the handle of a console app I came up with this and it works great.class Program{ [DllImport("user32.dll")] [return: MarshalAs(UnmanagedType.Bool)] static extern bool FlashWindowEx(ref FLASHWINFO pwfi); [StructLayout(LayoutKind.Sequential)] public struct FLASHWINFO { public UInt32 cbSize; public IntPtr hwnd; public UInt32 dwFlags; public UInt32 uCount; public Int32 dwTimeout; } public const UInt32 FLASHW_ALL = 3; static void Main(string[] args) { Console.WriteLine("Flashing NOW"); FlashWindow(Process.GetCurrentProcess().MainWindowHandle); Console.WriteLine("Press any key to continue"); Console.ReadKey(); } private static void FlashWindow(IntPtr hWnd) { FLASHWINFO fInfo = new FLASHWINFO(); fInfo.cbSize = Convert.ToUInt32(Marshal.SizeOf(fInfo)); fInfo.hwnd = hWnd; fInfo.dwFlags = FLASHW_ALL; fInfo.uCount = UInt32.MaxValue; fInfo.dwTimeout = 0; FlashWindowEx(ref fInfo); }} 这篇关于有没有一种方法可以使控制台窗口以编程方式在任务栏中闪烁的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
09-13 15:05