有没有一种方法可以使控制台窗口以编程方式在任务栏中闪烁

编程入门 行业动态 更新时间:2024-10-06 12:29:27
本文介绍了有没有一种方法可以使控制台窗口以编程方式在任务栏中闪烁的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

基本上,我制作了控制台应用程序,执行一些需要几分钟的任务。我想让它在任务栏中闪烁,以便在完成任务时通知我。

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); } }

更多推荐

有没有一种方法可以使控制台窗口以编程方式在任务栏中闪烁

本文发布于:2023-11-03 04:50:23,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1554279.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:控制台   栏中   窗口   方式   方法

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!