如何防止窗口被停用?
有什么办法可以防止窗口被停用吗?该窗口的进程与我的不同。
这是针对 Windows 的。
Is there any way to prevent a window from being deactivated? The window is in a different process then mine.
This is for Windows.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这样做可能很危险,但解决方案是处理 WM_ACTIVATE 消息并检查 wParam 是否为 WA_INACTIVE。这意味着该窗口已被停用。发生这种情况时,您只需重新激活它即可。
为了对另一个进程的窗口执行此操作,您需要使用
SetWindowsHookEx
安装消息挂钩。然而,另一个应用程序可能会做同样的事情,使彼此陷入激活/停用的无限循环中。
这也是在个人计算机上运行的软件绝对不应该做的事情。
Doing this can be dangerous, but the solution is to handle the WM_ACTIVATE message and check if the wParam is WA_INACTIVE. This means the window has been deactivated. When this happens, you can just reactivate it.
In order to do this for another process's window, you will need to install a message hook with
SetWindowsHookEx
.However, it is possible that another application could do the same thing, putting each other in an endless loop of activation/deactivation.
This is also something that should never be done by software that is meant to run on a personal computer.
您可以捕获
WM_ACTIVATEAPP
像这样:You can trap the
WM_ACTIVATEAPP
like this: