ColorAtScreenLoc Function

Mark Schonewille m.schonewille at economy-x-talk.com
Tue Jan 21 13:32:02 EST 2014


Hi Ray,

This function doesn't involve moving the mouse cursor.

function screenlocColor
    put the screenloc into myLoc
    add 31 to item 1 of myLoc
    add 31 to item 2 of myLoc
    put (the screenLoc),myLoc into myRect
    export snapshot from rectangle myRect to myPixels as PNG
    set the text of the templateImage to myPixels
    put char 1 to 4 of the imageData of the templateImage into myPixel
    return charToNum(char 2 of myPixel), \
      charToNum(char 3 of myPixel),charToNum(char 4 of myPixel)
    reset the templateImage
end screenlocColor

--
Best regards,

Mark Schonewille

Economy-x-Talk Consulting and Software Engineering
Homepage: http://economy-x-talk.com
Twitter: http://twitter.com/xtalkprogrammer
KvK: 50277553

Use Color Converter to convert CMYK, RGB, RAL, XYZ, H.Lab and other 
colour spaces. http://www.color-converter.com

Buy my new book "Programming LiveCode for the Real Beginner" 
http://qery.us/3fi

Fill out this survey please
http://livecodebeginner.economy-x-talk.com/survey/

On 1/21/2014 18:28, Ray wrote:
> Anybody know of a function which returns the color of the screen at a
> given location?  Simply pass it a point and get the color of that pixel,
> kind of like a combination of the mouseColor function and the
> controlAtScreenLoc function.  I'd be happy if it only worked for points
> on Livecode stacks.  I've tried 'click at loc [myPoint] and then getting
> the mouseColor but it doesn't work.





More information about the use-livecode mailing list