我怎样才能克服“焦点窃取者”问题? Windows 7 中的预防措施?
ShowWindow 功能不再像宣传的那样工作,这可能是由于“焦点窃取”限制,我认为在修改了 ForegroundLockTimeout 注册表设置后就绕过了该限制。即使我在注册表中将其设置为 0,我的调用仍然失败。
我正在尝试使用 ShowWindow 通过键盘快捷键从 SysTray 隐藏中拉出一些程序。我将一些 C# 应用程序绑定到这些热键。例如,我用它来拉出 Total Commander(因为它的标准功能已损坏):
//Win32API.ShowWindow((IntPtr)hwndTC, Win32API.ShowWindowCommand.ShowDefault);
Win32API.ShowWindow((IntPtr)hwndTC, Win32API.ShowWindowCommand.ShowMaximized);
//Win32API.ShowWindow((IntPtr)hwndTC, Win32API.ShowWindowCommand.Maximize);
//Win32API.SetWindowPos(hwndTC, Win32API.HWND_TOPMOST, 0, 0, 0, 0,
// Win32API.SWP_NOSIZE | Win32API.SWP_NOMOVE);
//Win32API.SetWindowPos(hwndTC, Win32API.HWND_NOTOPMOST, 0, 0, 0, 0,
// Win32API.SWP_NOSIZE | Win32API.SWP_NOMOVE);
Win32API.SetWindowPos(hwndTC, Win32API.HWND_TOP, 0, 0, 0, 0,
Win32API.SWP_NOSIZE | Win32API.SWP_NOMOVE | Win32API.SWP_SHOWWINDOW);
Win32API.SetForegroundWindow(hwndTC);
有很多注释代码,因为我尝试了所有方法。在 Windows XP 上,只需简单调用 ShowWindow 即可完美运行。在 Windows 7 上,情况一团糟。它的行为很混乱并且很少起作用。
当以管理员身份运行时,它有点可以工作。除了我试图显示的窗口将开始在任务栏上闪烁而不是显示。完全是个谜。
The ShowWindow
function doesn't work as advertised any more and it's likely due to "focus stealing" restrictions, which I thought bypassed once I modified the ForegroundLockTimeout
registry setting. Even though I set it to 0 everywhere in the Registry, my calls still fail.
I'm trying to use ShowWindow to pull some programs out of SysTray hiding via keyboard shortcuts. I bound some C# apps to those hotkeys. For example, I use this, to pull Total Commander out (as its standard functionality is broken):
//Win32API.ShowWindow((IntPtr)hwndTC, Win32API.ShowWindowCommand.ShowDefault);
Win32API.ShowWindow((IntPtr)hwndTC, Win32API.ShowWindowCommand.ShowMaximized);
//Win32API.ShowWindow((IntPtr)hwndTC, Win32API.ShowWindowCommand.Maximize);
//Win32API.SetWindowPos(hwndTC, Win32API.HWND_TOPMOST, 0, 0, 0, 0,
// Win32API.SWP_NOSIZE | Win32API.SWP_NOMOVE);
//Win32API.SetWindowPos(hwndTC, Win32API.HWND_NOTOPMOST, 0, 0, 0, 0,
// Win32API.SWP_NOSIZE | Win32API.SWP_NOMOVE);
Win32API.SetWindowPos(hwndTC, Win32API.HWND_TOP, 0, 0, 0, 0,
Win32API.SWP_NOSIZE | Win32API.SWP_NOMOVE | Win32API.SWP_SHOWWINDOW);
Win32API.SetForegroundWindow(hwndTC);
There is a lot of commented code because I tried everything. On Windows XP this worked perfectly with a simple call to ShowWindow. On Windows 7, it's a mess. It behaves chaotically and rarely works.
When running as an administrator, it kind of works. Except that the window I'm trying to show will start blinking on the taskbar instead of being shown. Complete mystery.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论