用于检测最小化窗口的钩子 C#
大家好 在C#中如何检测用户单击了外部程序(例如记事本)的最小化按钮? 谢谢
Hi all
How can I detect in C # that the user clicked on the minimize button of an external program (eg notepad)?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这应该有效:
编辑:只需重新阅读您的问题,并注意到您希望在记事本最小化时收到通知。那么您可以在计时器中使用上面的代码来轮询状态更改。
This should work:
Edit: Just re-read you question and noticed you wanted to be notified when Notepad get minimized. Well you could use the code above in a timer to poll the status change.
正如汉斯·帕桑特(Hans Passant)所说,你无法将其最小化。
不过,我相信您可以存储窗口的状态,并在稍后查看它们是否最小化。
通过使用 GetWindowPlacement 函数。
As Hans Passant said you cannot get the event of it being minimized.
Although, I believe you can store the states of windows and see if they are minimized at a later interval.
by using the GetWindowPlacement Function.
上面的答案有一个错误。
您需要检查
placement.showCMD
,而不是placement.flags
请参阅https://msdn.microsoft.com/en-us/library/windows/desktop/ms632611(v=vs.85)。 ASPX
The answer above has an error.
You need to check
placement.showCMD
, notplacement.flags
Please see https://msdn.microsoft.com/en-us/library/windows/desktop/ms632611(v=vs.85).aspx