Simple Color Picker

As a web designer [well … debatable], I often have a need for color pickers, etc. While most are freely available, some have bloated feature sets I don’t even need, or too clunky to use. I’ve always pined for something easy to get at, out of the way, but allowed me to grab a triplet when I needed it and move on …

choose color

It’s amazing just how something so simple can be so incredibly useful. :smiley:

Here’s a quick color picker for AppleScript, that copies the color as a string for use in AppleScript (Studio):


set myColor to choose color
set colorstring to my getstring(myColor)
set theanswer to button returned of (display dialog "Copy " & colorstring & " to the clipboard?")
if theanswer is "OK" then set the clipboard to colorstring

on getstring(theColor)
	set cs to "{"
	repeat with c from 1 to 3
		set cs to cs & (item c of theColor) as string
		if c < 3 then
			set cs to cs & ", "
		else
			set cs to cs & "}"
		end if
	end repeat
	return cs
end getstring

For those who want a stay-open application, compile this code as an XCode project with 3 buttons and a text field (named and connected appropriately) and the “on will launch” connection made to file’s owner.


on launched theObject
	set color of color panel to {65535, 0, 0}
	set visible of color panel to true
end launched

on clicked theObject
	if name of theObject is "show" then
		set colorstring to my getstring()
		set contents of text field "colortext" of window "main" to colorstring
	else if name of theObject is "clip" then
		set colorstring to my getstring()
		set contents of text field "colortext" of window "main" to colorstring
		set the clipboard to colorstring
	else if name of theObject is "picker" then
		set visible of color panel to true
	end if
end clicked

on getstring()
	set myColor to color of color panel
	set cs to "{"
	repeat with c from 1 to 3
		set cs to cs & (item c of myColor)
		if c < 3 then
			set cs to cs & ", "
		else
			set cs to cs & "}"
		end if
	end repeat
	return cs
end getstring