Note that there are some explanatory texts on larger screens.

plurals
  1. POCan't detect color of a pixel in a pixel that... changes color
    primarykey
    data
    text
    <p>I am trying to create an application that when the color of a pixel on screen changes to another one (that I know what it is) it does something, doesn't really matter to the question what it does.</p> <p>Anyway, I am using this:</p> <pre><code> CGImageRef window283x420 = CGWindowListCreateImage(NSMakeRect(284, 420, 1, 1), kCGWindowListOptionOnScreenOnly, kCGNullWindowID, kCGWindowImageDefault); NSBitmapImageRep *cannonOne = [[NSBitmapImageRep alloc] initWithCGImage:window283x420]; </code></pre> <p>Then, the color I am expecting it to change to here:</p> <pre><code>NSColor *color = [NSColor colorWithCalibratedRed:0.521569 green:0.380392 blue:0.231373 alpha:1]; </code></pre> <p>And am comparing the colors here:</p> <pre><code>while (![color isEqualToColor:[cannonOne colorAtX:0 y:0]]) { CGImageRef window283x420 = CGWindowListCreateImage(NSMakeRect(284, 420, 1, 1), kCGWindowListOptionOnScreenOnly, kCGNullWindowID, kCGWindowImageDefault); NSBitmapImageRep *cannonOne = [[NSBitmapImageRep alloc] initWithCGImage:window283x420]; if ([color isEqualToColor:[cannonOne colorAtX:0 y:0]]) { </code></pre> <p>I know the while/if part could be done better, but it should work just fine and not worrying about optimizing the app until it actually works lol.</p> <p>Now, if for example the color of the pixel doesn't actually change fast (like the color stays like that for a bit) it works perfectly. If it is like a pixel with a color that moves around and reaches 283*420 but doesn't stay there for long (like 0.1s) (as described in the example above) it doesn't work.</p> <p>The time it stays there shouldn't be a problem, as my app is checking the pixel really fast, as seen in the debug here:</p> <pre><code>2010-01-04 22:12:58.230 appname[2372:a0f] Checked 2010-01-04 22:12:58.231 appname[2372:a0f] Checked </code></pre> <p>Any ideas? :)</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload