Skip to content

Instantly share code, notes, and snippets.

@praschl
Forked from Danik/capslock_remap_alt.ahk
Last active August 8, 2017 13:25
Show Gist options
  • Select an option

  • Save praschl/c83b983fc93f9a49755d8d1460caf26a to your computer and use it in GitHub Desktop.

Select an option

Save praschl/c83b983fc93f9a49755d8d1460caf26a to your computer and use it in GitHub Desktop.
Autohotkey Capslock Remapping Script. Makes Capslock function as a modifier key to get cursor keys etc. on the left side of the keyboard, so you never have to move your hand to the right.
; The original script can be found at https://gist.github.com/Danik/5808330 (forked from there)
; Adapt to german layout:
; Capslock + Z - PageUp (changed from Y)
; And some new key remappings for better accessibility of {[]}\/ and adapt to german layout:
; Capslock + ( - [
; Capslock + ) - ]
; Capslock + ? - \
; Capslock + / - {
; Capslock + = - }
; Capslock + - - /
;
; Capslock + h - Word left
; Capslock + ö - Word right
;
; also "Win Key + Capslock work like Capslock" has been deactivated (commented), who needs Capslock anyway?
; Autohotkey Capslock Remapping Script
; Danik
; More info at http://danikgames.com/blog/?p=714
; danikgames.com
;
; Functionality:
; - Deactivates capslock for normal (accidental) use.
; - Hold Capslock and drag anywhere in a window to move it (not just the title bar).
; - Access the following functions when pressing Capslock:
; Cursor keys - J, K, L, I
; Enter - Space
; Home, End, PgDn, PgUp - U, O, Z, H
; Backspace and Del - N, M
;
; Select all - A
; Cut, copy, paste - S, D, F
; Close tab, window, Escape - W, E, R
; Next, previous tab - Tab, Q
; Undo, redo - , and .
;
; To use capslock as you normally would, you can press WinKey + Capslock
; This script is mostly assembled from modified versions of the following awesome scripts:
;
; # Home Row Computing by Gustavo Duarte: http://duartes.org/gustavo/blog/post/home-row-computing for
; Changes:
; - Does not need register remapping of AppsKey using SharpKeys.
; - Uses normal cursor key layout
; - Added more hotkeys for insert, undo, redo etc.
;
; # Get the Linux Alt+Window Drag Functionality in Windows: http://www.howtogeek.com/howto/windows-vista/get-the-linux-altwindow-drag-functionality-in-windows/
; Changes: The only change was using Capslock instead of Alt. This
; also removes problems in certain applications.
#Persistent
SetCapsLockState, AlwaysOff
; easier []{}\/ on german layout
Capslock & (::Send {Blind}`[
Capslock & )::Send {Blind}`]
Capslock & /::Send {Blind}{{}
Capslock & =::Send {Blind}{}}
Capslock & ?::Send {Blind}\
Capslock & -::Send {Blind}/
; Caplock + hö (Ctrl Left, Ctrl right)
Capslock & h::SendInput {Ctrl Down}{Left Down}
Capslock & h up::SendInput {Ctrl Up}{Left Up}
Capslock & ö::SendInput {Ctrl Down}{Right Down}
Capslock & ö up::SendInput {Ctrl Up}{Right Up}
;
; Reload script automatically on Ctrl-S :-)
; deactivated by ;
;~^s::
;reload
;return
; Capslock + jkli (left, down, up, right)
Capslock & j::Send {Blind}{Left DownTemp}
Capslock & j up::Send {Blind}{Left Up}
Capslock & k::Send {Blind}{Down DownTemp}
Capslock & k up::Send {Blind}{Down Up}
Capslock & i::Send {Blind}{Up DownTemp}
Capslock & i up::Send {Blind}{Up Up}
Capslock & l::Send {Blind}{Right DownTemp}
Capslock & l up::Send {Blind}{Right Up}
; Capslock + uohy (pgdown, pgup, home, end)
Capslock & u::SendInput {Blind}{Home Down}
Capslock & u up::SendInput {Blind}{Home Up}
Capslock & o::SendInput {Blind}{End Down}
Capslock & o up::SendInput {Blind}{End Up}
Capslock & ü::SendInput {Blind}{PgUp Down}
Capslock & ü up::SendInput {Blind}{PgUp Up}
Capslock & ä::SendInput {Blind}{PgDn Down}
Capslock & ä up::SendInput {Blind}{PgDn Up}
; Capslock + asdf (select all, cut-copy-paste)
Capslock & a::SendInput {Ctrl Down}{a Down}
Capslock & a up::SendInput {Ctrl Up}{a Up}
Capslock & s::SendInput {Ctrl Down}{x Down}
Capslock & s up::SendInput {Ctrl Up}{x Up}
Capslock & d::SendInput {Ctrl Down}{c Down}
Capslock & d up::SendInput {Ctrl Up}{c Up}
Capslock & f::SendInput {Ctrl Down}{v Down}
Capslock & f up::SendInput {Ctrl Up}{v Up}
; Capslock + wer (close tab or window, press esc)
Capslock & w::SendInput {Ctrl down}{F4}{Ctrl up}
Capslock & e::SendInput {Alt down}{F4}{Alt up}
Capslock & r::SendInput {Blind}{Esc Down}
; Capslock + nm (backspace, del)
Capslock & m::SendInput {Blind}{Del Down}
Capslock & n::SendInput {Blind}{BS Down}
Capslock & BS::SendInput {Blind}{BS Down}
; Make Capslock & Enter equivalent to Control+Enter
Capslock & Enter::SendInput {Ctrl down}{Enter}{Ctrl up}
; Make Capslock & Alt Equivalent to Control+Alt
!Capslock::SendInput {Ctrl down}{Alt Down}
!Capslock up::SendInput {Ctrl up}{Alt up}
; Capslock + TAB/q (prev/next tab)
Capslock & q::SendInput {Ctrl Down}{Tab Down}
Capslock & q up::SendInput {Ctrl Up}{Tab Up}
Capslock & Tab::SendInput {Ctrl Down}{Shift Down}{Tab Down}
Capslock & Tab up::SendInput {Ctrl Up}{Shift Up}{Tab Up}
; Capslock + ,/. (undo/redo)
Capslock & ,::SendInput {Ctrl Down}{z Down}
Capslock & , up::SendInput {Ctrl Up}{z Up}
Capslock & .::SendInput {Ctrl Down}{y Down}
Capslock & . up::SendInput {Ctrl Up}{y Up}
; Make Capslock+Space -> Enter
Capslock & Space::SendInput {Enter Down}
; Make Win Key + Capslock work like Capslock
; Deactivated, who needs Capslock?
;#Capslock::
;If GetKeyState("CapsLock", "T") = 1
; SetCapsLockState, AlwaysOff
;Else
; SetCapsLockState, AlwaysOn
;Return
; Drag windows anywhere
;
; This script modified from the original: http://www.autohotkey.com/docs/scripts/EasyWindowDrag.htm
; by The How-To Geek
; http://www.howtogeek.com
Capslock & LButton::
CoordMode, Mouse ; Switch to screen/absolute coordinates.
MouseGetPos, EWD_MouseStartX, EWD_MouseStartY, EWD_MouseWin
WinGetPos, EWD_OriginalPosX, EWD_OriginalPosY,,, ahk_id %EWD_MouseWin%
WinGet, EWD_WinState, MinMax, ahk_id %EWD_MouseWin%
if EWD_WinState = 0 ; Only if the window isn't maximized
SetTimer, EWD_WatchMouse, 10 ; Track the mouse as the user drags it.
return
EWD_WatchMouse:
GetKeyState, EWD_LButtonState, LButton, P
if EWD_LButtonState = U ; Button has been released, so drag is complete.
{
SetTimer, EWD_WatchMouse, off
return
}
GetKeyState, EWD_EscapeState, Escape, P
if EWD_EscapeState = D ; Escape has been pressed, so drag is cancelled.
{
SetTimer, EWD_WatchMouse, off
WinMove, ahk_id %EWD_MouseWin%,, %EWD_OriginalPosX%, %EWD_OriginalPosY%
return
}
; Otherwise, reposition the window to match the change in mouse coordinates
; caused by the user having dragged the mouse:
CoordMode, Mouse
MouseGetPos, EWD_MouseX, EWD_MouseY
WinGetPos, EWD_WinX, EWD_WinY,,, ahk_id %EWD_MouseWin%
SetWinDelay, -1 ; Makes the below move faster/smoother.
WinMove, ahk_id %EWD_MouseWin%,, EWD_WinX + EWD_MouseX - EWD_MouseStartX, EWD_WinY + EWD_MouseY - EWD_MouseStartY
EWD_MouseStartX := EWD_MouseX ; Update for the next timer-call to this subroutine.
EWD_MouseStartY := EWD_MouseY
return
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment