Skip to content

Instantly share code, notes, and snippets.

@h2m730131
Last active August 4, 2025 03:31
Show Gist options
  • Save h2m730131/da324c5e625cdf999c4bc26760dff399 to your computer and use it in GitHub Desktop.
Save h2m730131/da324c5e625cdf999c4bc26760dff399 to your computer and use it in GitHub Desktop.
Remap the Keyboard in Windows: AutoHotkey
; GroupAdd, Vim_Only, ahk_exe devenv.exe ; Visual Studio 2019
; GroupAdd, Vim_Only, ahk_exe Code.exe ; Visual Studio Code
; GroupAdd, Vim_Only, ahk_exe msedge.exe ; Edge
; Left Alt + h / j / k / l 為方向鍵
; #IfWinActive ahk_group Vim_Only
; <!h::Send {Left}
; <!j::Send {Down}
; <!k::Send {Up}
; <!l::Send {Right}
; #IfWinActive
<!h::Send {Left}
<!j::Send {Down}
<!k::Send {Up}
<!l::Send {Right}
; Left Ctrl + J 切換輸入語言 (Left Alt + Shift)
<^J::
KeyWait, Ctrl
KeyWait, J
; Send {LAlt down}{Shift}{LAlt up} ; {LAlt down}{Shift down}{Shift up}{LAlt up} 中文輸入法的輸入模式會交替互換,這次為中文、下次換英數字元
; {Shift down}{LAlt down}{LAlt up}{Shift up} 切換輸入語言後,會停留在工具列上 (e.g., File)
Send {LAlt down}{Shift down}{LAlt up}{Shift up} ; 避免中文輸入法的輸入模式會交替互換
Return
#If !IsExcludedApp()
^h::Send, {Backspace}
^d::Send, {Delete}
#If
IsExcludedApp() {
WinGet, exeName, ProcessName, A
if exeName in Code.exe,devenv.exe,bash.exe,WindowsTerminal.exe
return true
return false
}
; CapsLock 鍵改成 Esc 鍵
*CapsLock::
KeyWait, CapsLock
If A_ThisHotkey = *CapsLock
Send, {Blind}{Esc}
Return
; Ctrl+Shift+O to open containing folder in Explorer.
; Ctrl+Shift+E to open folder with current file selected.
; Supports SciTE and Notepad++.
; ^+o::
; ^+e::
; editor_open_folder() {
; WinGetTitle, path, A
; if RegExMatch(path, "\*?\K(.*)\\[^\\]+(?= [-*] )", path)
; if (FileExist(path) && A_ThisHotkey = "^+e")
; Run explorer.exe /select`,"%path%"
; else
; Run explorer.exe "%path1%"
; }
; Moving the Mouse Cursor via the Keyboard
; *#up::MouseMove, 0, -10, 0, R ; Win+UpArrow hotkey => Move cursor upward
; *#Down::MouseMove, 0, 10, 0, R ; Win+DownArrow => Move cursor downward
; *#Left::MouseMove, -10, 0, 0, R ; Win+LeftArrow => Move cursor to the left
; *#Right::MouseMove, 10, 0, 0, R ; Win+RightArrow => Move cursor to the right
;
; *<#RCtrl:: ; LeftWin + RightControl => Left-click (hold down Control/Shift to Control-Click or Shift-Click).
; SendEvent {Blind}{LButton down}
; KeyWait RCtrl ; Prevents keyboard auto-repeat from repeating the mouse click.
; SendEvent {Blind}{LButton up}
; return
;
; *<#AppsKey:: ; LeftWin + AppsKey => Right-click
; SendEvent {Blind}{RButton down}
; KeyWait AppsKey ; Prevents keyboard auto-repeat from repeating the mouse click.
; SendEvent {Blind}{RButton up}
; return
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment