如何使用 autohotkey 模拟 Windows 10 中的超键
How to emulate hyper key in Windows 10 using autohotkey
我正在将我的 mac 工作流程迁移到 Windows。我离不开的一件事是超级键,它是 Ctrl
+ Option
+ Shift
+ Cmd
的组合。我使用 Karabiner 应用程序将 Capslock
重新映射到此 Hyper
键。我听说 Autohotkey 是 Windows 的 Karabiner 替代品。你们能帮我在 Windows 中模拟这个功能吗?
我理想的结果是:
- 完全停用
Capslock
因为我很少用这个
- 切换
Capslock
将执行ESC
键
- 按住
Capslock
会执行Ctrl
+Alt
+Shift
+Windows
。例如 Capslock + C
将是 Ctrl+Alt+Shift+Windows+C
非常感谢!
以下是我对 ahk 脚本的尝试,但它根本不起作用:(
;-----------------------------------------
; hyper key for windows
;=========================================
; --------------------------------------------------------------
; notes
; --------------------------------------------------------------
; ! = alt
; ^ = ctrl
; + = shift
; # = lwin|rwin
;
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
#UseHook
#InstallKeybdHook
#SingleInstance force
SendMode Input
;; deactivate capslock completely
SetCapslockState, AlwaysOff
;; remap capslock to hyper
Capslock::
SendInput {Blind}{Ctrl Down}{Alt Down}{Shift Down}{LWin Down}
return
Capslock up::
SendInput {Blind}{Ctrl Up}{Alt Up}{Shift Up}{LWin Up}
return
;; vim navigation with hyper
^!+#h:: SendInput {Blind}{Left}
^!+#h up:: SendInput {Blind}{Left Up}
^!+#l:: SendInput {Blind}{Right}
^!+#k:: SendInput {Blind}{Up}
^!+#j:: SendInput {Blind}{Down}
;; popular hotkeys with hyper
^!+#c::^c
^!+#v::^v
感谢任何试图帮助我的人,我自己弄清楚了这个问题,并想分享它以防有人遇到这个问题。
#NoEnv ; recommended for performance and compatibility with future autohotkey releases.
#UseHook
#InstallKeybdHook
#SingleInstance force
SendMode Input
;; deactivate capslock completely
SetCapslockState, AlwaysOff
;; remap capslock to hyper
;; if capslock is toggled, remap it to esc
;; note: must use tidle prefix to fire hotkey once it is pressed
;; not until the hotkey is released
~Capslock::
;; must use downtemp to emulate hyper key, you cannot use down in this case
;; according to https://autohotkey.com/docs/commands/Send.htm, downtemp is as same as down except for ctrl/alt/shift/win keys
;; in those cases, downtemp tells subsequent sends that the key is not permanently down, and may be
;; released whenever a keystroke calls for it.
;; for example, Send {Ctrl Downtemp} followed later by Send {Left} would produce a normal {Left}
;; keystroke, not a Ctrl{Left} keystroke
Send {Ctrl DownTemp}{Shift DownTemp}{Alt DownTemp}{LWin DownTemp}
KeyWait, Capslock
Send {Ctrl Up}{Shift Up}{Alt Up}{LWin Up}
if (A_PriorKey = "Capslock") {
Send {Esc}
}
return
;; vim navigation with hyper
~Capslock & h:: Send {Left}
~Capslock & l:: Send {Right}
~Capslock & k:: Send {Up}
~Capslock & j:: Send {Down}
;; popular hotkeys with hyper
~Capslock & c:: Send ^{c}
~Capslock & v:: Send ^{v}
您可以在此处使用 Karabiner 的一名随员:
https://github.com/Vonng/Capslock/blob/master/win/CapsLock.ahk
它映射了您在 Mac
上习惯使用的相同热键
;Summary: |
;o----------------------o---------------------------------------------o
;|CapsLock; | {ESC} Especially Convient for vim user |
;|CaspLock + ` | {CapsLock}CapsLock Switcher as a Substituent|
;|CapsLock + hjklwb | Vim-Style Cursor Mover |
;|CaspLock + uiop | Convient Home/End PageUp/PageDn |
;|CaspLock + nm,. | Convient Delete Controller |
;|CapsLock + zxcvay | Windows-Style Editor |
;|CapsLock + Direction | Mouse Move |
;|CapsLock + Enter | Mouse Click |
;|CaspLock + {F1}~{F6} | Media Volume Controller |
;|CapsLock + qs | Windows & Tags Control |
;|CapsLock + ;'[] | Convient Key Mapping |
;|CaspLock + dfert | Frequently Used Programs (Self Defined) |
;|CaspLock + 123456 | Dev-Hotkey for Visual Studio (Self Defined) |
;|CapsLock + 67890-= | Shifter as Shift |
要安装它,请按照 doc 中的以下步骤进行操作:
- 右键单击您的桌面。
- 在菜单中找到“新建”。
- 点击“新建”菜单中的“AutoHotkey 脚本”。
- 为脚本命名。它必须以 .ahk 扩展名结尾。例如:
MyScript.ahk
- 在桌面上找到新创建的文件并右键单击它。
- 点击“编辑脚本”。
- 应该弹出一个window,可能是记事本。如果是这样,那就成功了!
- 保存文件。
- 双击桌面上的file/icon即可运行。打开记事本或(您可以输入的任何内容)并按
Ctrl
和 J
。
- 嘻嘻万岁!您的第一个脚本已完成。去获得一些奖励零食,然后 return 阅读本教程的其余部分。
我正在将我的 mac 工作流程迁移到 Windows。我离不开的一件事是超级键,它是 Ctrl
+ Option
+ Shift
+ Cmd
的组合。我使用 Karabiner 应用程序将 Capslock
重新映射到此 Hyper
键。我听说 Autohotkey 是 Windows 的 Karabiner 替代品。你们能帮我在 Windows 中模拟这个功能吗?
我理想的结果是:
- 完全停用
Capslock
因为我很少用这个 - 切换
Capslock
将执行ESC
键 - 按住
Capslock
会执行Ctrl
+Alt
+Shift
+Windows
。例如Capslock + C
将是Ctrl+Alt+Shift+Windows+C
非常感谢!
以下是我对 ahk 脚本的尝试,但它根本不起作用:(
;-----------------------------------------
; hyper key for windows
;=========================================
; --------------------------------------------------------------
; notes
; --------------------------------------------------------------
; ! = alt
; ^ = ctrl
; + = shift
; # = lwin|rwin
;
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
#UseHook
#InstallKeybdHook
#SingleInstance force
SendMode Input
;; deactivate capslock completely
SetCapslockState, AlwaysOff
;; remap capslock to hyper
Capslock::
SendInput {Blind}{Ctrl Down}{Alt Down}{Shift Down}{LWin Down}
return
Capslock up::
SendInput {Blind}{Ctrl Up}{Alt Up}{Shift Up}{LWin Up}
return
;; vim navigation with hyper
^!+#h:: SendInput {Blind}{Left}
^!+#h up:: SendInput {Blind}{Left Up}
^!+#l:: SendInput {Blind}{Right}
^!+#k:: SendInput {Blind}{Up}
^!+#j:: SendInput {Blind}{Down}
;; popular hotkeys with hyper
^!+#c::^c
^!+#v::^v
感谢任何试图帮助我的人,我自己弄清楚了这个问题,并想分享它以防有人遇到这个问题。
#NoEnv ; recommended for performance and compatibility with future autohotkey releases.
#UseHook
#InstallKeybdHook
#SingleInstance force
SendMode Input
;; deactivate capslock completely
SetCapslockState, AlwaysOff
;; remap capslock to hyper
;; if capslock is toggled, remap it to esc
;; note: must use tidle prefix to fire hotkey once it is pressed
;; not until the hotkey is released
~Capslock::
;; must use downtemp to emulate hyper key, you cannot use down in this case
;; according to https://autohotkey.com/docs/commands/Send.htm, downtemp is as same as down except for ctrl/alt/shift/win keys
;; in those cases, downtemp tells subsequent sends that the key is not permanently down, and may be
;; released whenever a keystroke calls for it.
;; for example, Send {Ctrl Downtemp} followed later by Send {Left} would produce a normal {Left}
;; keystroke, not a Ctrl{Left} keystroke
Send {Ctrl DownTemp}{Shift DownTemp}{Alt DownTemp}{LWin DownTemp}
KeyWait, Capslock
Send {Ctrl Up}{Shift Up}{Alt Up}{LWin Up}
if (A_PriorKey = "Capslock") {
Send {Esc}
}
return
;; vim navigation with hyper
~Capslock & h:: Send {Left}
~Capslock & l:: Send {Right}
~Capslock & k:: Send {Up}
~Capslock & j:: Send {Down}
;; popular hotkeys with hyper
~Capslock & c:: Send ^{c}
~Capslock & v:: Send ^{v}
您可以在此处使用 Karabiner 的一名随员: https://github.com/Vonng/Capslock/blob/master/win/CapsLock.ahk
它映射了您在 Mac
上习惯使用的相同热键;Summary: |
;o----------------------o---------------------------------------------o
;|CapsLock; | {ESC} Especially Convient for vim user |
;|CaspLock + ` | {CapsLock}CapsLock Switcher as a Substituent|
;|CapsLock + hjklwb | Vim-Style Cursor Mover |
;|CaspLock + uiop | Convient Home/End PageUp/PageDn |
;|CaspLock + nm,. | Convient Delete Controller |
;|CapsLock + zxcvay | Windows-Style Editor |
;|CapsLock + Direction | Mouse Move |
;|CapsLock + Enter | Mouse Click |
;|CaspLock + {F1}~{F6} | Media Volume Controller |
;|CapsLock + qs | Windows & Tags Control |
;|CapsLock + ;'[] | Convient Key Mapping |
;|CaspLock + dfert | Frequently Used Programs (Self Defined) |
;|CaspLock + 123456 | Dev-Hotkey for Visual Studio (Self Defined) |
;|CapsLock + 67890-= | Shifter as Shift |
要安装它,请按照 doc 中的以下步骤进行操作:
- 右键单击您的桌面。
- 在菜单中找到“新建”。
- 点击“新建”菜单中的“AutoHotkey 脚本”。
- 为脚本命名。它必须以 .ahk 扩展名结尾。例如:
MyScript.ahk
- 在桌面上找到新创建的文件并右键单击它。
- 点击“编辑脚本”。
- 应该弹出一个window,可能是记事本。如果是这样,那就成功了!
- 保存文件。
- 双击桌面上的file/icon即可运行。打开记事本或(您可以输入的任何内容)并按
Ctrl
和J
。 - 嘻嘻万岁!您的第一个脚本已完成。去获得一些奖励零食,然后 return 阅读本教程的其余部分。