且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在Windows窗体中禁用Alt + Tab

更新时间:2022-12-23 13:55:00

看到这个页面:

http://social.msdn.microsoft.com /论坛/ zh-CN / 3a931e08-6830-49a0-852b-ca0c89781ad4 / a-way-to-disable-the-alttab-windows-key?forum = Vsexpressvcs [ ^ ]
See this page:
http://social.msdn.microsoft.com/Forums/en-US/3a931e08-6830-49a0-852b-ca0c89781ad4/a-way-to-disable-the-alttab-windows-key?forum=Vsexpressvcs[^]


在做了一些研究之后,我能想出的***答案是你无法做到。我已经尝试了谷歌发现的几个如何禁用alt-tab解决方案的代码。他们都没有禁用此特定功能。



这是问题所在。您可以影响应用程序处理的击键。因此,您可以捕获并取消可在控件之间移动的Tab键。您可以过滤掉进入文本框的击键。您可以忽略键盘上的数字,同时允许通过键盘顶部的键输入。



但是你无法阻止Windows完成它的工作。您无法阻止大写锁定键在键盘上切换。您无法阻止用户使用ctrl-alt-delete来启动任务管理器来取消您的应用程序。使用它时,您无法阻止他们上网。您不能让驻留进程对他们正在监视的击键做出反应。



这是安全和正确的行为。您不应该编写一个随意影响其他应用程序的应用程序。有多少次表现糟糕的应用程序被冻结,你需要alt-tab远离,或者ctrl-alt-delete来调用任务管理器来取消应用程序?如果这个表现糟糕的应用程序无法将焦点转移到其他功能上会有多烦人。您可以随时关闭计算机,然后再打开,这是真的。但是如果黑客经理将该应用程序插入到您的启动过程中呢?好的,有安全模式或引导程序,但你明白了。馊主意。你为什么要这样做?人们应该能够拥有多个可访问的应用程序,以防程序冻结或者在程序运行时需要执行其他工作。
After doing a good bit of research, the best answer that I can come up with is you can't do it. I've tried the code for several of the "how can I disable alt-tab" solutions that google finds. None of them disable this specific functionality.

Here's the problem. You can influence the keystrokes that are processed by the application. So you can catch and cancel a tab key that would move you between controls. You can filter out keystrokes that are going into your text box. You can ignore numbers from the keypad while allowing those entered via keys across the top of the keyboard.

But you can't stop Windows from doing its job. You can't keep the capslock key from being toggled on your keyboard. You can't keep users from ctrl-alt-delete to bring up the task manager to cancel your application. You can't keep them from surfing the web while using it. You can't keep resident processes from reacting to keystrokes that they are monitoring for.

This is safe and proper behavior. You shouldn't be able to write an application that affects other applications so casually. How many times has a badly behaved application frozen up and you have needed to alt-tab away, or ctrl-alt-delete to call up task manager to cancel the application? How annoying it would be if this badly behaved application made it impossible to shift focus to other functionality. You can always turn your computer off and on again, true. But what if a hacker manager to get that application inserted into your startup processes? OK, there's safe mode or a booter but you get the idea. Bad idea. Why would you want to do it? People should be able to have multiple accessible applications in case your program freezes or they need to perform other work while it is running.