当您使用键盘时,没有什么比意外敲击破坏性按键更令人沮丧的事情了。例如,Windows键可以使某些全屏应用程序最小化。
有时按下Alt键可以完全阻止之后的所有键输入。(Alt)如果您在不知情的情况下不小心敲击了这些键,可能会造成很大的不便和混乱。
许多允许您在Windows上禁用按键输入的常用解决方案现已过时。例如,Simple Disable Key不再是免费软件。最新版本的 Windows(Windows)不(KeyTweak)正式支持SharpKeys和KeyTweak(SharpKeys)。那么,当你没有选择的时候,你会怎么做?你建立你自己的!
不过不要被吓倒——这非常容易。在本文中,我们将向您展示如何使用名为AutoHotKey的免费(AutoHotKey)Windows应用程序禁用您想要的任何键。最好的部分是它不需要任何复杂的配置或重新启动即可生效。
下载并安装 AutoHotKey
在Windows(Windows)机器上禁用任何键盘输入的第一步是下载一个名为AutoHotKey的程序。最新版本的链接将位于页面顶部的蓝色按钮中。下载AutoHotKey后,运行安装程序。
使用默认选项继续(Continue)安装提示,如上所示。安装完成后,您可以完全关闭它。我们还不需要启动AutoHotKey。
构建你的 AutoHotKey 脚本
现在您已经下载了AutoHotKey,了解它的作用很重要。AutoHotKey允许您创建自己的自定义脚本,它将编译和运行。将AutoHotKey(Think)视为一种专门针对自动化和创建Windows 键盘快捷键(Windows keyboard shortcuts)的(AutoHotKey)简化编程语言。
学习一门编程语言很困难,但我们在这里简化了如何使用AutoHotKey的功能来禁用任何键盘按键的输入。
选择你的钥匙
第一步是选择要禁用的键。前往AutoHotKey(Head)文档网站查找所有(AutoHotKey)受支持键的列表(list of all supported keys)。
为了这个例子,我们想要禁用Caps Lock键。在此页面上,您可以看到AutoHotKey将该键引用为“ CapsLock ”。左列显示参考名称,右列显示它对应的键。
打开文本编辑器
接下来,打开任何文本编辑器。它甚至可以是我们将使用的记事本。(Notepad)在空白文档中,键入密钥的参考名称,后跟“ ::return ”。
这是我们的Caps Lock示例的外观:
你能相信这是禁用密钥所需的唯一代码行吗?如果您决定要禁用多个键,则可以在新行上为每个附加键重复相同的一行。
保存您的脚本
下一步是保存脚本,以便它可以运行。您需要为此选择一个永久位置,可能不在您的桌面上,因为稍后我将向您展示如何让该脚本在启动时运行。
在此示例中,我们选择了 Documents 中的“Scripts”文件夹。选择保存位置后,将“保存类型(Save as type)”更改为“所有文件(All Files)”。然后,输入您选择的文件名并确保附加“ .ahk ”扩展名。这个非常重要。
将您的文件保存为AHK可以让您的系统知道它打算由AutoHotKey编译和运行。
运行 AutoHotKey 脚本
保存AHK文件后,在Windows Explorer中导航到它的保存位置。您应该看到文件的图标是一张纸,上面有一个“H”,这意味着它与AutoHotKey相关联。
双击(Double-click)该文件。您可能没有注意到任何事情发生,但您应该会看到AutoHotKey图标出现在任务栏的系统托盘中。
它可能在您看到它时被隐藏,因此在这种情况下,您需要单击向上箭头图标以显示隐藏的系统托盘图标(system tray icons)。
现在,尝试使用您已禁用的密钥。它有效吗?如果没有,您已成功禁用密钥!如果是这样,你可能做错了什么。仔细阅读说明并重试。
控制你的 AutoHotKey 脚本
右键单击任务栏系统托盘中的AutoHotKey图标将弹出以下菜单:
值得一提的两个重要选项是“重新加载(Reload)此脚本”和“暂停热键”。
有时您可能希望在AutoHotKey脚本正在运行时对其进行编辑。例如,也许您想添加另一个键来阻止。保存对AHK(AHK)文件的更改后,选择“重新加载此脚本(Reload This Script)”选项。这将允许您加载脚本的更改,而无需关闭并重新打开文件。
如果您想阻止AutoHotKey阻止任何键,请选择“暂停热键(Suspend Hotkeys)”选项。AutoHotKey 的托盘图标将从“H”变为“S”,表示热键被阻止。要重新启用所有热键,请再次重复相同的操作。
在启动时运行脚本
现在您的脚本已经开始工作了,您可能会认为这非常重要,以至于您希望它自动从Windows启动。这很容易做到。
按Windows + R键调出 Window 的运行(Run)提示。在其中输入“ %appdata% ”并按Enter。这将带您进入“AppData”内的“Roaming”文件夹。
在这里,浏览以下文件夹:Microsoft > Windows > Start Menu > Programs > Startup。在另一个Windows 资源管理器(Windows Explorer)菜单中,导航到保存AutoHotKey脚本的文件夹。(AutoHotKey)右键单击它,然后单击“创建快捷方式(Create shortcut)”。这将为同一文件夹中的文件创建一个快捷方式。
将该快捷方式拖放(Drag)到“启动(Startup)”文件夹中。
通过这种方式将脚本添加到您的启动中,您可以对文件的原始位置进行编辑,而不是每次都一直导航到该文件夹。如果您经常进行编辑,这将大大节省时间。
这就是它所需要的。使用AutoHotKey(AutoHotKey)脚本中的简单一行,您可以禁用键盘上的任何标准键,让您免于数小时的头痛。不要在网上到处寻找简单而免费的解决方案来解决这个问题,请按照本指南自己制作一个!
Disable Keyboard Keys in Windows with AutoHotKey
When you’re at yоur keyboard, not too many thіngs аre as frustrating as aсcidentallу hitting a disruptive key. For examplе, thе Windоws key can cause some fullscreen applications to minimize.
Pressing the Alt key can sometimes completely block all key inputs thereafter. If you’re accidentally hitting these keys without knowing, it can cause major inconveniences and confusion.
Many of the usual solutions that allow you to disable key inputs on Windows are now outdated. For example, Simple Disable Key is no longer freeware. Both SharpKeys and KeyTweak aren’t officially supported by the latest versions of Windows. So, what do you do when you’re out of options? You build your own!
Don’t be intimidated though—it’s extremely easy. In this article, we’re going to show you how you can disable any and every key you want using a free Windows application called AutoHotKey. The best part is that it doesn’t require any complicated configuration or rebooting to take effect.
Download and Install AutoHotKey
The first step to disabling any keyboard input on your Windows machine is to download a program called AutoHotKey. The link to the latest version will be at the top of the page in a blue button. Once you’ve downloaded AutoHotKey, run the installer.
Continue through the installation prompts using the default options, shown above. When the installation is complete, you can close out of it entirely. We don’t need to launch AutoHotKey just yet.
Building Your AutoHotKey Script
Now that you’ve downloaded AutoHotKey, it’s important to understand what it does. AutoHotKey allows you to create your own custom scripts that it will compile and run. Think of AutoHotKey as a simplified programming language that caters specifically to automation and creating Windows keyboard shortcuts.
Learning a programming language is hard, but we’re here to simplify how you can use the powers of AutoHotKey to disable the input of any of your keyboard’s keys.
Pick Your Keys
The first step is to pick out which keys you want to disable. Head over to the AutoHotKey documentation website to find a list of all supported keys.
For the sake of this example, we want to disable the Caps Lock key. On this page, you can see that AutoHotKey references that key as “CapsLock”. The left column shows the reference name(s) and the right column shows what key it corresponds with.
Open a Text Editor
Next, open any text editor. It can even be Notepad, which we’ll use. In a blank document, type the key’s reference name followed by “::return”.
Here’s how our Caps Lock example looks:
Can you believe that’s the only line of code you need to disable the key? If you decide that you want to disable more than one, you can repeat this same one-liner, on a new line, for each additional key.
Save Your Script
The next step is to save the script so that it can be run. You’ll want to pick a permanent spot for this, probably not on your desktop, because I’ll show you how to get this script to run at startup later.
In this example, we’ve chosen the “Scripts” folder within our Documents. After you choose a location to save it, change the “Save as type” to “All Files”. Then, type in a filename of your choice and be sure to append the “.ahk” extension. This is very important.
Saving your file as an AHK lets your system know that it’s intended to be compiled and run by AutoHotKey.
Running Your AutoHotKey Script
After you’ve saved your AHK file, navigate to where it’s saved at in Windows Explorer. You should see that the file’s icon is a sheet of paper with an “H” on it, meaning it’s associated with AutoHotKey.
Double-click the file. You may not notice anything happen, but you should see the AutoHotKey icon appear in your taskbar’s system tray.
It may be hidden by the time you see it, so you’ll need to click the upwards arrow icon to show your hidden system tray icons in that case.
Now, try using the key that you’ve disabled. Does it work? If not, you’ve successfully disabled the key! If so, you may have done something wrong. Read over the instructions more carefully and try again.
Controlling Your AutoHotKey Script
Right-clicking on the AutoHotKey icon in your taskbar’s system tray will bring up the following menu:
The two important options worth touching on are “Reload This Script” and “Suspend Hotkeys”.
There may come a time when you’ll want to edit your AutoHotKey script while it’s actively running. Maybe you want to add another key to block, for example. After saving your changes to the AHK file, select the “Reload This Script” option. This will allow you to load your script’s changes without having to close and reopen the file.
If you ever want to stop AutoHotKey from blocking any keys, select the “Suspend Hotkeys” option. Your AutoHotKey’s tray icon will change from an “H” to an “S” to indicate that hotkeys are being blocked. To re-enable all hotkeys, repeat this same action again.
Running Your Script on Startup
Now that you’ve got your script working, you may decide this is so important that you want it to automatically start with Windows. That’s easy to do.
Press the Windows + R keys to bring up the Window’s Run prompt. In it, type “%appdata%” and hit Enter. This will bring you to the “Roaming” folder inside of “AppData”.
Here, go through the following folders: Microsoft > Windows > Start Menu > Programs > Startup. In another Windows Explorer menu, navigate to the folder where your AutoHotKey script is saved. Right-click on it and click “Create shortcut”. This will create a shortcut for the file in that same folder.
Drag and drop that shortcut into the “Startup” folder.
Adding the script to your startup this way allows you to make edits to the file’s original location rather than navigating all the way to this folder each time. If you make frequent edits, this is a big time-saver.
That’s all it takes. With one simple line in an AutoHotKey script, you can disable any standard key on your keyboard and save yourself from hours of headaches. Don’t shop around the web for a simple and free solution to this problem, follow this guide and make one yourself!