get the color of a pixel

Greetings,

I need to get the color of a pixel in a window that does not necessarily have a canvas object. This use to work: currentColor=tabletop.graphics.pixel(x,y).
The pixel may be within any number of canvases or objects. Jason K offered a partial solution, except I do not use a mouse action event. He used the following

dim s as new Shell
s.Execute “screencapture -c -x”
s.Close
dim clip as new Clipboard
dim p as picture = clip.Picture
clip.Close
dim rgbs as RGBSurface = p.RGBSurface
dim c as color = rgbs.Pixel(system.Mousex, system.mousey)
'Break //c is the color under the mouse

theColor = c
Canvas1.Invalidate

maybe there is an easier way?

Thanks!

CG

If you got the Monkeybread plugins, you can directly get the color of a pixel from the screen with ScreenshotRectMBS.

It seems to me that if you replace System.MouseX, System.MouseY with the X, Y of the pixel you want (and leave out Canvas1.Invalidate), it should work.

Actually… You’ll need to add the top and left position of the window to the y and x coordinates, respectively.