使用 WM_SHOWWINDOW 显示窗口而不是 ShowWindow()
我正在尝试使用热键实用程序(或 NirCMD 等)的 SendMessage 功能来弹出隐藏窗口。例如,我可以通过发送 0x0010 (WM_CLOSE) 来关闭窗口,但是当我尝试发送 wParam 为 1 且 lParam 为 0 的 0x0018 (WM_SHOWWINDOW) 时,什么也没有发生。
我环顾四周,发现有人抱怨 WM_SHOWWINDOW 不起作用的少数地方,他们很高兴地接受了使用 ShowWindow() 的建议。
但是我没有 ShowWindow() 可用;我只能发送 Windows 消息。但 ShowWindow() 并不神奇,它肯定是通过 SendMessage-ing WM_SHOWWINDOW 或幕后的东西来工作的。
如何通过向窗口发送消息来使其自动显示?
谢谢。
I’m trying to use the SendMessage function of a hotkey utility (or NirCMD, etc.) to get a hidden window to pop up. I can for example get windows to close by sending 0x0010 (WM_CLOSE), but when I try sending 0x0018 (WM_SHOWWINDOW) with a wParam of 1 and an lParam of 0, nothing happens.
I’ve looked around, and the few places where someone complained that WM_SHOWWINDOW did not work, they happily took the suggestion to use ShowWindow() instead.
However I don’t have ShowWindow() available; I can only send Windows messages. But ShowWindow() is not magic, surely it works by SendMessage-ing a WM_SHOWWINDOW or something under the covers.
How can I get a window to display itself by sending it a message?
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
尝试这两条消息:
或者,如果可以使用第 3 方应用程序,请尝试 cmdow
Try these two messages:
Or if using 3rd party apps is ok, try cmdow
WM_SHOWWINDOW 是一个通知,而不是一个命令。来自 MSDN:
我不相信有任何消息可以用来让窗口自动显示。事实上,这个想法对我来说似乎有点奇怪。窗口管理器是负责显示和隐藏窗口的系统组件。要显示窗口,您必须使用窗口管理器 API 之一。
WM_SHOWWINDOW is a notification, not a command. From MSDN:
I don't believe there is any message that you can use to make a window show itself. Actually, the very idea seems a little strange to me. The window manager is the system component responsible for showing and hiding windows. To show a window, you must use one of the window manager APIs.
我认为使用
SendMessage
无法没有办法实现这一点(WM_SYSCOMMAND 对我不起作用)。我实际上在 C# 中尝试过。单击该按钮,窗口将通过ShowWindow()
最小化,然后您可以看到发送了哪些消息:I think there is no way to achieve that with
SendMessage
(WM_SYSCOMMAND didn't work for me). I tried actually in C#. You click the button, the window will be minimized viaShowWindow()
and then you can see what messages are sent: