Created
February 4, 2026 18:56
-
-
Save Krzysiu/daac1bc1da2dbd110991b4cb80853173 to your computer and use it in GitHub Desktop.
AutoHotKey - pick color directly from your screen
This file contains hidden or 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
| ; Preview: https://imgur.com/nL7VnYd | |
| ; This is a color picker - click to pick from anywhere on the screen, not just color pallete | |
| ; GUI serves just as an example of the function (PickColor to pick, Pick to start pick mode) | |
| ; Optional ideas: | |
| ; Screen freeze - take a screenshot and display it as borderless window all over the screen | |
| ; Live preview - set timer to 50 ms and use PickColor patrially | |
| #NoEnv | |
| SendMode Input | |
| CoordMode, Pixel, Screen | |
| CoordMode, Mouse, Screen | |
| SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory. | |
| Gui, Add, Progress, x165 y100 w145 h35 c00ff00 vColorPreview, 100 ; color preview - progress bar seems to be easiest way for a colored square | |
| Gui, Add, Text, y70 x39 w400 h20, %1% | |
| Gui, Font, s24 | |
| Gui, Add, Button, x10 y10 w300 h50 gPick, ColorPick ; trigger to start picking mode | |
| Gui, Font, s16 | |
| Gui, Add, Edit, x10 y100 w150 h35 vColor ReadOnly Center, PICK COLOR | |
| Gui, +AlwaysOnTop | |
| Gui, Show, x127 y87 h145 w320, Color picker | |
| pickButton:= "LButton" ; actual key that picks the color from the screen | |
| return | |
| GuiClose: | |
| Exit: | |
| Gui, submit, nohide | |
| ExitApp | |
| Return | |
| Pick: | |
| ; this starts color picking mode | |
| Gui, Hide ; hide GUI, because Murphy's law says the color you'll want to pick will be behind GUI | |
| Hotkey, %pickButton%, PickColor, On | |
| return | |
| ^y:: ; another, keyboard trigger to start picking mode | |
| PickColor: | |
| ; this actually picks color | |
| MouseGetPos, x, y | |
| PixelGetColor, probed, %x%, %y%, RGB ; default is BGR because why not | |
| editprobed := SubStr(probed, 3) ; the above fn returns 0x...... | |
| GuiControl,, Color, %editprobed% | |
| GuiControl, +c%probed%, ColorPreview | |
| Gui, Show | |
| Hotkey, %pickButton%, PickColor, Off ; no more picking | |
| return |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment