Does anyone know how I can find a pixel on screen using RGB value (or any other method) which will work on both mac and windows?
In VB.net, I would simply create a loop that will search from point: 0,0 to the whole screen ((My.Computer.Screen.Bounds.Width, My.Computer.Screen.Bounds.Height)), then use an if statement that will return true or false if that pixel = that RGB color.
something like this
But I have no clue how to do this on Xojo. Can anyone help.
@James - You could use api on both to obtain a screenshot image, putting it into a picture object, and use the graphics.pixel or RGBSurface pixel point of the picture object in reference of the mouse X Y cordinates. This will return the color code. If you search my posts for “screenshot” you should find windows, mac, and linux functions I’ve posted. Btw I’ve been busy working on some projects and should have more webbot material for you tomorrow.
So the best fastest free method is to use window api and cocoa apis… Screenshot method is actually slower than the method I’m about to describe (by MS…negligible).
You can use CGDisplayCreateImageForRect to get a CGImageRef that encompasses the point you’re interested in. Once you have a CGImage, you can get a color value out of it by rendering the image into a memoryblock and Picture.FromData(NameofMemoryBlock)), or by using NSBitmapImageRep’s initWithCGImage and then colorAtX:y:.
In obj C it would look like the following (easy xojo convert :-)):
Windows has a singular built-in function which I’m sure MBS plugins use called BitBlt to grab the screen and even faster than using Xojo’s builtin functions for RGBSurface/graphics.Pixel, is the windows GetPixel function itself.