Last active
August 29, 2015 14:21
AutoHotkey Script that lets you increment/decrement a selected number in a body of text
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
; Adds shortcuts to increment/decrement a selected number in a body of text | |
; Use Shift + Mouse Wheel | |
AddSelection( sign ) | |
{ | |
Send ^c | |
if( RegExMatch( clipboard, "^-?[0-9.]+$" ) ) ; is number | |
{ | |
; determine smallest increment | |
dotPos := InStr( clipboard, "." ) | |
numLen := StrLen( clipboard ) | |
if( dotPos > 0 ) | |
{ | |
exponent := numLen-dotPos | |
epsilon := 10**-exponent | |
SetFormat, float, 0.%exponent% | |
} | |
else | |
{ | |
epsilon := 1 | |
} | |
num := clipboard | |
num := num + sign * epsilon | |
clipboard = %num% | |
numLen := StrLen( clipboard ) | |
Send ^v | |
Loop, %numLen% | |
{ | |
SendInput +{Left} | |
} | |
} | |
} | |
+WheelUp:: | |
AddSelection( 1 ) | |
return | |
+WheelDown:: | |
AddSelection( -1 ) | |
return | |
; alternative shift plus mouse move control | |
; pixelStep := 10 | |
; ~LShift:: | |
; ~RShift:: | |
; MouseGetPos, xpos | |
; prevPos := xpos | |
; while GetKeyState("LShift", "P") or GetKeyState("RShift", "P") | |
; { | |
; MouseGetPos, xpos | |
; delta := Floor((xpos-prevPos) / pixelStep) | |
; if( delta != 0 ) | |
; { | |
; AddSelection( delta ) | |
; } | |
; prevPos := xpos | |
; Sleep, 100 | |
; } | |
; return |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment