Last active
April 6, 2025 03:17
-
-
Save phakeandy/91e9ff77f3aaf5064eebd3326c11322c to your computer and use it in GitHub Desktop.
ahk v1 脚本, 处理键盘映射
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; 需要安装 AutoHotKey v1 `scoop install extras/autohotkey` | |
; ================ | |
; vim-like 按键映射 | |
; ================ | |
!h::Send, {Left} ; Alt+H -> 左箭头 | |
!j::Send, {Down} ; Alt+J -> 下箭头 | |
!k::Send, {Up} ; Alt+K -> 上箭头 | |
!l::Send, {Right} ; Alt+L -> 右箭头 | |
+!h::Send, ^{Left} ; Alt+Shift+H -> Ctrl+左箭头 | |
+!l::Send, ^{Right} ; Alt+Shift+L -> Ctrl+右箭头 | |
; ================== | |
; emacs-like 按键映射 | |
; ================== | |
>^w::Send, ^{Backspace} ; >^ -> Right Control | |
>^a::Send, {Home} | |
>^e::Send, {End} | |
>^f::Send, ^{Right} | |
>^b::Send, ^{Left} | |
>^p::Send, ^{Up} | |
>^n::Send, ^{Down} | |
>!f::Send, ^{Right} | |
>!b::Send, ^{Left} | |
>!d::Send, ^{Delete} | |
; ================== | |
; F区 键盘映射 | |
; ================== | |
; !1::Send, {F1} | |
; !2::Send, {F2} | |
; !3::Send, {F3} | |
; !4::Send, {F4} | |
; !5::Send, {F5} | |
; !9::Send, {F9} | |
#SingleInstance Force | |
#NoEnv | |
; 定义长按的时间阈值(毫秒) | |
longPressThreshold := 200 | |
; 重新定义 CapsLock | |
; #If | |
; *CapsLock:: | |
; SetTimer, WaitForCapsLockCombos, 10 | |
; pressedTime := A_TickCount | |
; return | |
; *CapsLock Up:: | |
; SetTimer, WaitForCapsLockCombos, Off | |
; if (A_PriorKey = "CapsLock") { | |
; if ((A_TickCount - pressedTime) < longPressThreshold) { | |
; SetCapsLockState, % GetKeyState("CapsLock", "T") ? "Off" : "On" | |
; } | |
; } | |
; return | |
; WaitForCapsLockCombos: | |
; ; F1-F12 映射 | |
; if (GetKeyState("1", "P")) { | |
; if ((A_TickCount - pressedTime) >= longPressThreshold) { | |
; SetTimer, WaitForCapsLockCombos, Off | |
; Send, {F1} | |
; } | |
; } | |
; else if (GetKeyState("2", "P")) { | |
; if ((A_TickCount - pressedTime) >= longPressThreshold) { | |
; SetTimer, WaitForCapsLockCombos, Off | |
; Send, {F2} | |
; } | |
; } | |
; else if (GetKeyState("3", "P")) { | |
; if ((A_TickCount - pressedTime) >= longPressThreshold) { | |
; SetTimer, WaitForCapsLockCombos, Off | |
; Send, {F3} | |
; } | |
; } | |
; else if (GetKeyState("4", "P")) { | |
; if ((A_TickCount - pressedTime) >= longPressThreshold) { | |
; SetTimer, WaitForCapsLockCombos, Off | |
; Send, {F4} | |
; } | |
; } | |
; else if (GetKeyState("5", "P")) { | |
; if ((A_TickCount - pressedTime) >= longPressThreshold) { | |
; SetTimer, WaitForCapsLockCombos, Off | |
; Send, {F5} | |
; } | |
; } | |
; else if (GetKeyState("6", "P")) { | |
; if ((A_TickCount - pressedTime) >= longPressThreshold) { | |
; SetTimer, WaitForCapsLockCombos, Off | |
; Send, {F6} | |
; } | |
; } | |
; else if (GetKeyState("7", "P")) { | |
; if ((A_TickCount - pressedTime) >= longPressThreshold) { | |
; SetTimer, WaitForCapsLockCombos, Off | |
; Send, {F7} | |
; } | |
; } | |
; else if (GetKeyState("8", "P")) { | |
; if ((A_TickCount - pressedTime) >= longPressThreshold) { | |
; SetTimer, WaitForCapsLockCombos, Off | |
; Send, {F8} | |
; } | |
; } | |
; else if (GetKeyState("9", "P")) { | |
; if ((A_TickCount - pressedTime) >= longPressThreshold) { | |
; SetTimer, WaitForCapsLockCombos, Off | |
; Send, {F9} | |
; } | |
; } | |
; else if (GetKeyState("0", "P")) { | |
; if ((A_TickCount - pressedTime) >= longPressThreshold) { | |
; SetTimer, WaitForCapsLockCombos, Off | |
; Send, {F10} | |
; } | |
; } | |
; else if (GetKeyState("-", "P")) { | |
; if ((A_TickCount - pressedTime) >= longPressThreshold) { | |
; SetTimer, WaitForCapsLockCombos, Off | |
; Send, {F11} | |
; } | |
; } | |
; else if (GetKeyState("=", "P")) { | |
; if ((A_TickCount - pressedTime) >= longPressThreshold) { | |
; SetTimer, WaitForCapsLockCombos, Off | |
; Send, {F12} | |
; } | |
; } | |
; return |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment