title: Get Pixel color fastest way?
body: <p>I'm trying to make an auto-cliker for an windows app. It works well, but it's incredibly slow!
  I'm currently using the method "getPixel" which reloads an array everytime it's called.</p>
  
  <p>Here is my current code:</p>
  
  <pre><code>hdc = GetDC(HWND_DESKTOP);
  bx = GetSystemMetrics(SM_CXSCREEN);
  by = GetSystemMetrics(SM_CYSCREEN);
  start_bx = (bx/2) - (MAX_WIDTH/2);
  start_by = (by/2) - (MAX_HEIGHT/2);
  end_bx = (bx/2) + (MAX_WIDTH/2);
  end_by = (by/2) + (MAX_HEIGHT/2);
  
  for(y=start_by; y&lt;end_by; y+=10)
  {   
      for(x=start_bx; x&lt;end_bx; x+=10)
      {
          pixel = GetPixel(*hdc, x, y);
          if(pixel==RGB(255, 0, 0))
          {
              SetCursorPos(x,y);
              mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0);
              Sleep(50);
              mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0);
              Sleep(25);
          }
      }
  }
  </code></pre>
  
  <p>So basically, it just scan a range of pixel in the screen and starts a mouse event if it detects a red button.</p>
  
  <p>I know there are other ways to get the pixel color, such as bitblt. But I've made some researches, and I don't understand how I'm supposed to do, in order to scan a color array. I need something which scans screen very fast in order to catch the button.</p>
  
  <p>Could you please help me?</p>
  
  <p>Thanks.</p>