有没有办法以编程方式使控制台窗口在任务栏中闪烁
基本上我制作了控制台应用程序来执行一些需要几分钟的任务。我想让它在任务栏中闪烁,让我知道它何时完成工作。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
使用 回答 @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.
结合 @Zack 评论中链接的问题的答案和 获取使用这个控制台窗口的 hwnd 我能够让它工作。这是我创建的类:
它永远不会停止闪烁,直到关闭为止,但这对我的目的来说并不重要。
Combining the answer in the question linked in @Zack's comment and getting the hwnd of a console window using this I was able to get it working. This is the class I created:
It doesn't ever stop flashing until it's closed but that wasn't important for my purposes.
我读到不可能通过任何直接方式获取控制台窗口的窗口句柄意思是,但实际上在 .NET 中似乎非常简单。所以,它与这个问题几乎相同:
I read that it wasn't possible to get the window handle of a console window through any direct means, but it seems to be pretty simple in .NET actually. So, it's pretty much the same as this question:
我调查了 @Davy8 遇到的问题,其中闪烁不停止。解决方案非常简单,只需传递 FLASHW_STOP 常量即可。为了展示这一点,我进一步增强了 @Davy8 的静态类以包含 StopFlashing 静态函数。我还决定根据 Microsoft 文档添加注释,以便很容易理解为什么这些内容应用于 C#。
I looked into the issue @Davy8 had in which the flashing doesn't stop. The solution was pretty simple, just pass the FLASHW_STOP constant. To show this, I further augmented @Davy8's static class to include a StopFlashing static function. I also decided to add comments based on the Microsoft Documentation such that it is easy to see why these are applied in C#.