Skip to content

Instantly share code, notes, and snippets.

@breakin
Last active August 31, 2020 10:57
Show Gist options
  • Save breakin/b68e416020c3848aa5a20eabb3675fed to your computer and use it in GitHub Desktop.
Save breakin/b68e416020c3848aa5a20eabb3675fed to your computer and use it in GitHub Desktop.
Script to get autohotkey to scroll when § is held and mouse moves up/down
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn ; Enable warnings to assist with detecting common errors.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
ox := 0
oy := 0
#Persistent
SetTimer, WatchCursor, 100
return
§::
; Eat this key
return
WatchCursor:
MouseGetPos, x, y
s := GetKeyState("§")
; If the weird key is held, check if mouse is going up or down
; Yes this will be problematic if mouse moves too fast, but only checks when weird key is held
if (s = 1) {
dx := x - ox
dy := y - oy
if (dy > 0) {
Loop 2
Click, WheelUp
}
if (dy < 0) {
Loop 2
Click, WheelDown
}
}
ox := x
oy := y
return
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment