如何劫持 Caps Lock 键以进行剪切、复制、粘贴键盘操作
这是我想要完成的任务:
- 要复制,请按并释放 Caps Lock 一次
- 要粘贴,请按并释放 Caps Lock 两次,快速
- 要剪切,请按 Ctrl+Caps Lock
我想要这样做的原因是我经常发现自己低头按下正确的 X/C/V 键,因为它们都在每个键旁边其他(至少在 QWERTY 键盘上)。
如何在标准键盘(使用 Windows)上执行此操作,以便它适用于整个系统并对所有应用程序(包括 Windows 资源管理器)透明?如果标准键盘无法实现,您认为任何“可编程数字键盘”都可以做到这一点吗?
在上面,“透明”的意思是“应用程序永远不应该知道这个击键已被翻译。它只获取常规的 Ctrl+X/C< /kbd>/V 代码,因此它的行为没有任何问题”。
诗。不确定适合此问题的所有标签,因此请随意添加更多标签。
解决了。更新: 感谢 @Jonno_FTW 向我介绍 AutoHotKey。 我通过在“我的文档”文件夹中的默认 AutoHotKey.ahk 文件中添加以下 AHK 脚本来管理所有三个要求:
Ctrl & CapsLock::
Send ^x
Return
CapsLock::
If (A_PriorHotKey = A_ThisHotKey and A_TimeSincePriorHotkey < 1000)
Send ^v
Else
Send ^c
Return
这很简单!
尚未完全解决。更新: 上述内容适用于记事本,但不适用于资源管理器(例如复制文件)或 MS Office(甚至文本复制也不起作用)。因此,我需要深入研究 AutoHotKey 或其他解决方案。当我找到解决方案时,会在这里发布解决方案。 同时,如果有人能让 AutoHotKey 满足我需要的一切,请回复!
全部解决了。更新: 我所要做的就是将大写“C”/X/Z 更改为小写“c”/x/z。所以 Send ^C 变成了 Send ^c。它现在适用于所有程序,包括 Windows 资源管理器!修复了上面的代码以反映此更改。
Here is what I am trying to accomplish:
- To Copy, press and release Caps Lock ONCE
- To Paste, press and release Caps Lock TWICE, quickly
- To Cut, press Ctrl+Caps Lock
The reason I want to do this is often times i find my self looking down to press the correct X/C/V key, since they're all next to each other (atleast on a QWERTY keyboard).
How can I do this on a standard keyboard (using Windows), so that it applies to the entire system and is transparent to all applications, including to Windows Explorer? If not possible with a standard keyboard, can any of the "programmable numeric keypads" do this you think?
In the above, by "transparent" I mean "the application should never know that this keystroke was translated. It only gets the regular Ctrl+X/C/V code, so it behaves without any problems".
Ps. Not sure of all the tags that are appropriate for this question, so feel free to add more tags.
SOLVED. UPDATE:
Thank you to @Jonno_FTW for introducing me to AutoHotKey.
I managed all three requirements by adding the following AHK script in the default AutoHotKey.ahk file in My Documents folder:
Ctrl & CapsLock::
Send ^x
Return
CapsLock::
If (A_PriorHotKey = A_ThisHotKey and A_TimeSincePriorHotkey < 1000)
Send ^v
Else
Send ^c
Return
That was easy!
NOT COMPLETELY SOLVED. UPDATE:
The above works in Notepad, but NOT in Explorer (copying files for example) or MS Office (even text copying does not work). So, I need to dig around a bit more into AutoHotKey or other solutions. Will post a solution here when I find one.
In the meantime, if someone can make AutoHotKey work for everything I need, please reply!
ALL SOLVED. UPDATE:
All I had to do was to change the capital "C"/X/Z to lowercase "c"/x/z. So Send ^C became Send ^c. It now works in ALL programs inlcuding Windows Explorer! Fixed code above to reflect this change.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我相信您正在寻找的程序是AutoHotkey。
I believe the program you are looking for is AutoHotkey.
您需要一个全局键盘挂钩。
You need a Global Keyboard Hook.
很不错!一直在寻找这样的东西有一段时间了。
我的脚本略有不同,使用 Shift 或控制组合进行剪切/复制,然后 CapsLock 本身总是粘贴。
如果您想保留保留 Caps Lock 功能的选项,我想您始终可以为此重新映射(例如 Alt-CapsLock)。当我尝试时,我无法让它正确切换。
Very nice! Been looking for something like this for a while.
My script is slightly different, making use of shift or control combinations for cut/copy, then CapsLock on its own is always paste.
If you wanted to retain the option of retaining the Caps Lock function, I presume you could always remap e.g. Alt-CapsLock for this. I couldn't get it to toggle correctly when I tried it though.