Skip to content

Instantly share code, notes, and snippets.

@oczki
Created January 5, 2021 19:17
Show Gist options
  • Save oczki/ef2c6b4ba044f3a7a5eb54306543b10d to your computer and use it in GitHub Desktop.
Save oczki/ef2c6b4ba044f3a7a5eb54306543b10d to your computer and use it in GitHub Desktop.
AutoHotkey: Control mouse pointer via keyboard + left/right click + scroll
#KeyHistory 0
#NoTrayIcon
#SingleInstance force
#Persistent
SetStoreCapslockMode, off
; Moves the mouse pointer, with a smaller jump if Shift is held.
MouseControl(deltaX, deltaY, regularJump := 60, smallJump := 8) {
multiplier := regularJump
if GetKeyState("Shift", "P")
multiplier := smallJump
MouseMove, deltaX * multiplier, deltaY * multiplier, 0, R
}
; Disable default Caps Lock handling (it can still be toggled with Ctrl + Caps Lock).
CapsLock::return
LCtrl & CapsLock::Send {CapsLock}
; Mouse control via keyboard
CapsLock & Up::MouseControl(0, -1)
CapsLock & Down::MouseControl(0, 1)
CapsLock & Left::MouseControl(-1, 0)
CapsLock & Right::MouseControl(1, 0)
CapsLock & Enter::Click
CapsLock & BS::Click, right
CapsLock & Home::Send {WheelUp}
CapsLock & End::Send {WheelDown}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment