windows 如何劫持 Caps Lock 键进行剪切、复制、粘贴键盘操作
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1550019/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to hiHyman the Caps Lock key for Cut, Copy, Paste keyboard operations
提问by Liao
Here is what I am trying to accomplish:
这是我想要完成的:
- To Copy, press and release Caps LockONCE
- To Paste, press and release Caps LockTWICE, quickly
- To Cut, press Ctrl+Caps Lock
- 要复制,请按下并松开Caps Lock一次
- 要粘贴Caps Lock,请快速按下并松开两次
- 要剪切,请按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).
我想要这样做的原因经常是我发现自己低头按下正确的 X/C/V 键,因为它们都彼此相邻(至少在 QWERTY 键盘上)。
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?
如何在标准键盘(使用 Windows)上执行此操作,以便它适用于整个系统并对所有应用程序(包括 Windows 资源管理器)透明?如果使用标准键盘无法实现,您认为任何“可编程数字小键盘”都可以做到这一点吗?
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/Vcode, so it behaves without any problems".
在上文中,通过“透明的”我的意思是“应用程序应该永远不会知道,这个按键被翻译,只获得常规Ctrl+ X/ C/V代码,因此它的表现没有任何问题”。
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:
解决了。更新:感谢@Jonno_FTW 向我介绍 AutoHotKey。我通过在 My Documents 文件夹的默认 AutoHotKey.ahk 文件中添加以下 AHK 脚本来管理所有三个要求:
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!
没有完全解决。更新:以上在记事本中有效,但不适用于资源管理器(例如复制文件)或 MS Office(即使文本复制也不起作用)。因此,我需要深入研究 AutoHotKey 或其他解决方案。当我找到一个解决方案时会在这里发布一个解决方案。同时,如果有人可以让 AutoHotKey 为我需要的一切工作,请回复!
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.
一切都解决了。更新:我所要做的就是将大写的“C”/X/Z 更改为小写的“c”/x/z。所以发送 ^C 变成了发送 ^c。它现在适用于包括 Windows 资源管理器在内的所有程序!修复了上面的代码以反映此更改。
采纳答案by Jonno_FTW
I believe the program you are looking for is AutoHotkey.
我相信您正在寻找的程序是AutoHotkey。
回答by Eric J.
You need a Global Keyboard Hook.
您需要一个全局键盘挂钩。
回答by Steve
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.
我的脚本略有不同,使用 shift 或 control 组合进行剪切/复制,然后 CapsLock 本身总是粘贴。
Ctrl & CapsLock::
Send ^x
Return
Shift & CapsLock::
Send ^c
Return
CapsLock::
Send ^v
Return
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.
如果您想保留保留大写锁定功能的选项,我认为您总是可以为此重新映射例如 Alt-CapsLock。但是,当我尝试它时,我无法正确切换。