Last active
October 31, 2022 07:37
-
-
Save grahamdyson/3029ef4fb4ad63eb132ce034727f58b1 to your computer and use it in GitHub Desktop.
This file contains 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
; MouseKeys alternative | |
; | |
; Uses number pad when not locked | |
; | |
; left button | |
; 5 | |
; | |
; toggle hold left button (e.g. multi-select, drag) | |
; / | |
; | |
; right button | |
; del | |
; | |
; 8 way directional movement with acceleration | |
; 1-4 and 7-9 | |
; | |
; scroll up and down in steps | |
; + and enter | |
; | |
; volume dial acts as mouse wheel | |
; alt key and volume dial acts as horizontal mouse wheel | |
; control key and volume dial acts as zoom mouse wheel | |
; | |
; jump to caret or control with focus | |
; * | |
; | |
; jump location across the screen | |
; - and 1-9 | |
Process, Priority,, H | |
#SingleInstance, force | |
#MaxHotkeysPerInterval 200 | |
moveMaximumSpeed := 100 ;pixels | |
moveTimeToMaximum := 3000 ;milliseconds | |
moveCurve := 1.8 ;1 is linear | |
wheelMaximumSpeed := 3 ;notches | |
wheelTimeToMaximum := 3000 ;milliseconds | |
wheelCurve := 1.4 ;1 is linear | |
CoordMode caret, screen | |
CoordMode mouse, screen | |
numLock := getKeyState("numLock", "T") | |
~numlock:: | |
numLock := getKeyState("numLock", "T") | |
leftHeld := false | |
soundBeep (numLock ? 500 : 2000) | |
return | |
#if !numLock | |
numpadClear:: | |
click down left | |
keyWait NumpadClear | |
click up left | |
return | |
^numpadClear:: | |
send {ctrl down} | |
click down left | |
keyWait NumpadClear | |
click up left | |
send {ctrl up} | |
return | |
numpadDel:: | |
click down right | |
keyWait NumpadDel | |
click up right | |
return | |
numpadDiv:: | |
if (leftHeld) { | |
click up left | |
leftHeld := false | |
} else { | |
click down left | |
leftHeld := true | |
} | |
return | |
numpadEnter:: wheelMoveWithAcceleration("WheelDown") | |
numpadEnter up:: wheelMoveWithAccelerationReset() | |
numpadAdd:: wheelMoveWithAcceleration("WheelUp") | |
numpadAdd up:: wheelMoveWithAccelerationReset() | |
wheelMoveWithAcceleration(direction) { | |
global wheelMaximumSpeed, wheelStartTime, wheelTimeToMaximum, wheelCurve | |
if (wheelStartTime) | |
speed := wheelMaximumSpeed * (((a_tickCount - wheelStartTime) / wheelTimeToMaximum) ** wheelCurve) | |
else | |
wheelStartTime := a_tickCount | |
wheelMove(direction, 1 + speed) | |
} | |
wheelMoveWithAccelerationReset() { | |
global wheelStartTime := 0 | |
} | |
; volume dial acts as mouse wheel | |
volume_down:: wheelMove("wheelUp", 1 + speed) | |
volume_up:: wheelMove("wheelDown", 1 + speed) | |
; alt key and volume dial acts as horizontal mouse wheel | |
!volume_down:: wheelMove("wheelLeft", 1 + speed) | |
!volume_up:: wheelMove("wheelRight", 1 + speed) | |
; control key and volume dial acts as zoom mouse wheel | |
^volume_down:: | |
send {ctrl down} | |
wheelMove("wheelUp", 1 + speed) | |
send {ctrl up} | |
return | |
^volume_up:: | |
send {ctrl down} | |
wheelMove("wheelDown", 1 + speed) | |
send {ctrl up} | |
return | |
; helper function for mouse wheel | |
wheelMove(direction, speed) { | |
mouseClick %direction%,,, speed, 0, D, R | |
} | |
; shift key volume dial flipped | |
+volume_down:: send {volume_up} | |
+volume_up:: send {volume_down} | |
; 8 way directional cursor movement | |
numpadHome:: mouseMoveRelative(-0.707, -0.707) | |
numpadHome up:: mouseMoveReset() | |
numpadUp:: mouseMoveRelative(0, -1) | |
numpadUp up:: mouseMoveReset() | |
numpadPgup:: mouseMoveRelative(0.707, -0.707) | |
numpadPgup up:: mouseMoveReset() | |
numpadRight:: mouseMoveRelative(1, 0) | |
numpadRight up:: mouseMoveReset() | |
numpadPgdn:: mouseMoveRelative(0.707, 0.707) | |
numpadPgdn up:: mouseMoveReset() | |
numpadDown:: mouseMoveRelative(0, 1) | |
numpadDown up:: mouseMoveReset() | |
numpadEnd:: mouseMoveRelative(-0.707, 0.707) | |
numpadEnd up:: mouseMoveReset() | |
numpadLeft:: mouseMoveRelative(-1, 0) | |
numpadLeft up:: mouseMoveReset() | |
mouseMoveRelative(x, y) { | |
global moveMaximumSpeed, moveStartTime, moveTimeToMaximum, moveCurve | |
if (moveStartTime) { | |
speed := moveMaximumSpeed * (((a_tickCount - moveStartTime) / moveTimeToMaximum) ** moveCurve) | |
mouseMove x * speed, y * speed, 0, R | |
} else { | |
moveStartTime := a_tickCount | |
mouseMove round(x), round(y), 0, R | |
} | |
} | |
mouseMoveReset() { | |
global moveStartTime := 0 | |
} | |
numpadMult:: | |
if (a_caretX && a_caretY) | |
mouseMove a_caretX, a_caretY | |
else { | |
controlGetFocus activeControl, A | |
if (ErrorLevel) { | |
winGetPos windowX, windowY, windowWidth, windowHeight, A | |
mouseMove windowX + (windowWidth / 2), windowY + (windowHeight / 2) | |
} else { | |
winGetPos windowX, windowY, , , A | |
controlGetPos controlX, controlY, controlWidth, controlHeight, %activeControl%, A | |
mouseMove windowX + controlX + (controlWidth / 2), windowY + controlY + (controlHeight / 2) | |
} | |
} | |
return | |
numpadSub & numpadClear:: mouseMoveAbsolute(0, 0) | |
numpadSub & numpadHome:: mouseMoveAbsolute(-1, -1) | |
numpadSub & numpadUp:: mouseMoveAbsolute(0, -1) | |
numpadSub & numpadPgup:: mouseMoveAbsolute(1, -1) | |
numpadSub & numpadRight:: mouseMoveAbsolute(1, 0) | |
numpadSub & numpadPgdn:: mouseMoveAbsolute(1, 1) | |
numpadSub & numpadDown:: mouseMoveAbsolute(0, 1) | |
numpadSub & numpadEnd:: mouseMoveAbsolute(-1, 1) | |
numpadSub & numpadLeft:: mouseMoveAbsolute(-1, 0) | |
mouseMoveAbsolute(x, y) { | |
mouseMove (a_screenWidth / 4) * ((x * 1.3) + 2), (a_screenHeight / 4) * ((y * 1.3) + 2) | |
} | |
; block group policy automatic locking | |
; SetTimer, pressF15, 600000 | |
; pressF15() { | |
; send {F15} | |
; } | |
; remap print screen key to open context menu on laptops missing the key | |
; PrintScreen::AppsKey |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment