Skip to content

Instantly share code, notes, and snippets.

@char101
Last active May 13, 2022 16:56
Show Gist options
  • Save char101/020c09ac769b9c62c5eec4fe4d3784f5 to your computer and use it in GitHub Desktop.
Save char101/020c09ac769b9c62c5eec4fe4d3784f5 to your computer and use it in GitHub Desktop.
[Autohotkey] Paste hex color into Windows color picker
HexToDec(h) {
SetFormat, integer, D
d := 0
d += "0x" h
return, d
}
PasteColor() {
c := Clipboard
If (RegExMatch(c, "^#[A-Za-z0-9]{6}$")) {
r := HexToDec(SubStr(c, 2, 2))
g := HexToDec(SubStr(c, 4, 2))
b := HexToDec(SubStr(c, 6, 2))
; MsgBox %c% -> %r% %g% %b%
ControlSetText, Edit4, %r%, A
ControlSetText, Edit5, %g%, A
ControlSetText, Edit6, %b%, A
} else {
MsgBox No recognized color found in clipboard
}
}
#IfWinActive Color ahk_class #32770
^v::PasteColor()
#IfWinActive
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment