"choose color" AppleScript doesn't work in Keyboard Maestro?

Any idea why this isn’t working? I’m trying to use the eyedropper tool to change font colors in my HTML, and this “script” works in Script Debugger but not in Keyboard Maestro as either a text script or script file:

choose color

the full script I’m looking to use is below, but if “choose color” doesn’t work it doesn’t matter:

set the RGB16bit_list to (choose color default color {65535, 50584, 0})

set the formatedColor to my RBG_to_HEX(RGB16bit_list)
set the clipboard to formatedColor

on RBG_to_HEX(RGB_values)
	-- this subroutine was taken from "http://www.apple.com/applescript/sbrt/sbrt-04.html"
	set the hex_list to {"0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F"}
	set the the hex_value to ""
	repeat with i from 1 to the count of the RGB_values
		set this_value to (item i of the RGB_values) div 256
		if this_value is 256 then set this_value to 255
		set x to item ((this_value div 16) + 1) of the hex_list
		set y to item (((this_value / 16 mod 1) * 16) + 1) of the hex_list
		set the hex_value to (the hex_value & x & y) as string
	end repeat
	return ("#" & the hex_value)
end RBG_to_HEX

To use Standard Additions methods like choose color you have to specify and activate a parent application. It can be anything, like "System Events" etc

When you run a script from SE or SD, they function as the parent application, but KM is essentially running an osascript command line in the shell, and there is no default application which can use the standard additions until you specify one.

1 Like

So simple! Thank you!

1 Like