Skip to content

Instantly share code, notes, and snippets.

@FaberVitale
Created April 17, 2021 16:32
Show Gist options
  • Save FaberVitale/e8f30efcd9f48ab8b2a022b2981b5ad4 to your computer and use it in GitHub Desktop.
Save FaberVitale/e8f30efcd9f48ab8b2a022b2981b5ad4 to your computer and use it in GitHub Desktop.
Color picker - Windows | Autohotkey
#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.
; Color Picker
; Usage: place mouse pointer over desired color then input "Win key + \ ",
; The picked color will be on the clipboard in rbg format
; https://www.autohotkey.com/docs/KeyList.htm
CoordMode, PixelGetColor, Screen
CoordMode, MouseGetPos, Screen
CoordMode, ToolTip, Screen
#\::getColor()
getColor()
{
xPos := ""
yPos := ""
pickedCol := ""
MouseGetPos, xPos, yPos
PixelGetColor, pickedCol, xPos, yPos, RGB
xTtip := xPos + 10
yTtip := yPos + 5
ToolTip, color picked!, xTtip, yTtip
SetTimer, FOLLOW_MOUSE, 16
Clipboard := hexToRgb(pickedCol)
SetTimer, HIDE_TOOLTIP, 800
}
hexToRgb(hex)
{
red := hex >> 16
green:= (hex & 0xFF00) >> 8
blue:= hex & 0xFF
return "rgb(" . red . ", " . green . ", " . blue . ")"
}
FOLLOW_MOUSE:
followMouse ()
{
xPos := ""
yPos := ""
MouseGetPos, xPos, yPos
xTtip := xPos + 10
yTtip := yPos + 5
ToolTip, color picked!, xTtip, yTtip
return
}
HIDE_TOOLTIP:
hideTooltip ()
{
SetTimer, FOLLOW_MOUSE, Off
SetTimer, HIDE_TOOLTIP, Off
ToolTip
return
}
@Arslan-TR
Copy link

u did a great job bro. I like it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment