Getting mouseColor from outside the app window

Mark Schonewille m.schonewille at economy-x-talk.com
Fri Oct 23 09:02:49 EDT 2009


Hi Kevin,

It is a bit slow, but it works:

function screenMouseColor theH,theV
      if number of items of theH is 2 then
           put item 2 of theH into theV
           put item 1 of theH into theH
      end if
      lock screen
      import snapshot from rectangle the screenrect
      put the long id of the last img into myImg
      put the imagedata of myImg into myData
      delete myImg
      put theH*(theV - 1)+theH into myPixel
      put char (myPixel + 1) to (myPixel + 3) of myData into myColor
      put charToNum(char 1 of myColor) & comma & charToNum(char 2 of  
myColor) \
             & comma & charToNum(char 3 of myColor) into myRGB
      unlock screen
      return myRGB
end screenMouseColor

There may be better ways to do this, besides an external, but I can't  
think of it right now.

--
Best regards,

Mark Schonewille

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

Download Strõm Flow Chart Software
http://flowproject.economy-x-talk.com

On 23 okt 2009, at 14:32, Kevin Stallibrass wrote:

> Hi,
>
>
>
> I want to sample the color under the cursor and am using
>
>
>
> set the cursor to cross
>
>  repeat until the mouseClick
>
>     set the backgroundColor of graphic "sample" to the mouseColor
>
>     put the mouseColor into fld "rgb"
>
>
>
>  end repeat
>
> set the cursor to arrow
>
>
>
> This works fine within the confines of the rev app window but is it  
> possible
> to sample a color from anywhere on the screen?
>
> Using the above script captures the color outside the rev app window  
> and
> puts the color into the graphic as the mouse moves but the  
> mouseClick is
> ignored when the cursor is outside the app window
>
> Seems logical that it should act this way but there must be a way to  
> get
> round this. I'd be grateful for any pointers
>
>
>
> Regards
>
>
>
> Kevin Stallibrass




More information about the use-livecode mailing list