I work with CSS files. Sometimes I want a HEX color slightly darker or brighter than an existing color. From your text editor, select something like 4E80B3 and press Ctrl+Alt+Shift+NumpadAdd (brighter) or Ctrl+Alt+Shift+NumpadSub (darker). The 6 characters will be replaced with the new color.
Code:
^!+NumpadAdd::
clipboard = ;
SendInput ^c
ClipWait
StringRight, rgb, clipboard, 6
StringRight, bb, rgb, 2
StringLeft, rr, rgb, 2
StringMid, gg, rgb, 3, 2
rr := "0x" . rr
gg := "0x" . gg
bb := "0x" . bb
SetFormat, integer, h
rr := Round(rr * 1.1)
gg := Round(gg * 1.1)
bb := Round(bb * 1.1)
StringRight, rr, rr, 2
StringRight, gg, gg, 2
StringRight, bb, bb, 2
SendInput %rr%%gg%%bb%
return
^!+NumpadAdd::
clipboard = ;
SendInput ^c
ClipWait
StringRight, rgb, clipboard, 6
StringRight, bb, rgb, 2
StringLeft, rr, rgb, 2
StringMid, gg, rgb, 3, 2
rr := "0x" . rr
gg := "0x" . gg
bb := "0x" . bb
SetFormat, integer, h
rr := Round(rr * 0.9)
gg := Round(gg * 0.9)
bb := Round(bb * 0.9)
StringRight, rr, rr, 2
StringRight, gg, gg, 2
StringRight, bb, bb, 2
SendInput %rr%%gg%%bb%
return
Can be improved:
* Does not check limits, so it messes up if you try to brighten FFFFFF or darken 000000.
* Would be great if the selection was not lost after pressing the keys, this way you could press them several times.
* I multiply by 1.1 or 0.9 to change the brighness. This is not very good, because it makes impossible to brighten black. Better would be use +10 and -10 for red, and adjust green and blue so the proportion to red is kept.
* A better way would be to show a brightness slider to adjust the color with a GUI.