Apple Colour (Color) Picker

Posted on
Sat Dec 21, 2013 7:07 pm
mat offline
Posts: 769
Joined: Nov 25, 2010
Location: Cambridgeshire - UK

Apple Colour (Color) Picker

Good evening,

I'm looking to use the apple colour picker to control my LED lights. The following script works as the colour picker when run outside of indigo, and can set the correct variable within indigo (which then changes the colour of the lights.

The issue is, I can't get the script to run either as a background script, or embedded. i get an error when embedding which states that "no user interaction allowed". Is this the same reason it won't run as a background script as I'm not seeing this in the error log?

Is there a way of running it from my MBP and setting a variable in indigo on the mini? Presumably there is no way of running this on iso devices?

Cheers

Mat

Code: Select all
property my_color : {0, 32896, 65535}
set my_color to choose color default color my_color
set red to round (first item of my_color) / 257
set green to round (second item of my_color) / 257
set blue to round (third item of my_color) / 257
set red_web to dec_to_hex(red)
set green_web to dec_to_hex(green)
set blue_web to dec_to_hex(blue)
set red_web to normalize(red_web, 2)
set green_web to normalize(green_web, 2)
set blue_web to normalize(blue_web, 2)
set red to normalize(red, 3)
set green to normalize(green, 3)
set blue to normalize(blue, 3)
set web_text to "#" & red_web & green_web & blue_web

tell application "IndigoServer"
   set value of variable "colourpicker" to web_text
end tell

on dec_to_hex(the_number)
   if the_number is 0 then
      return "0"
   end if
   set hex_list to {"0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F"}
   set the_result to ""
   set the_quotient to the_number
   repeat until the_quotient is 0
      set the_quotient to the_number div 16
      set the_result to (item (the_number mod 16 + 1) of hex_list) & the_result
      set the_number to the_quotient
   end repeat
   return the_result
end dec_to_hex
on normalize(the_number, the_length)
   set the_number to the_number as string
   --if length of the_number ? the_length then
   --   return the_number
   --end if
   repeat until length of the_number is equal to the_length
      set the_number to "0" & the_number
   end repeat
   return the_number
end normalize

Late 2018 mini 10.14

Posted on
Mon Dec 23, 2013 4:47 pm
matt (support) offline
Site Admin
User avatar
Posts: 21426
Joined: Jan 27, 2003
Location: Texas

Re: Apple Colour (Color) Picker

Since this script shows UI I don't think it is possible, except from an external script (via the Script Editor) or perhaps if you save the script as a script application. It isn't going to be possible to run it embedded in Indigo since the Indigo Server (which runs the script) has no UI at all.

Image

Posted on
Tue Dec 24, 2013 4:06 am
mat offline
Posts: 769
Joined: Nov 25, 2010
Location: Cambridgeshire - UK

Re: Apple Colour (Color) Picker

Thanks Matt. Guess it wouldn't work embedded and that it would stop indigo from doing anything else.

Will give the script application a go.

Happy holidays

Late 2018 mini 10.14

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 3 guests