title: Get middle screen pixel (color) in C# (full screen game)?
body: <p>I'm running a full screen game and I'm trying to find out the color of the middle pixel. The code I'm using however, seems to only work with windowed applications/games/etc. This is my code: </p>
  
  <pre><code>public static Color GetPixelColor(int x, int y) 
  {
      IntPtr hdc = GetDC(IntPtr.Zero);
      uint pixel = GetPixel(hdc, x, y);
      ReleaseDC(IntPtr.Zero, hdc);
      Color color = Color.FromArgb((int)(pixel &amp; 0x000000FF),
              (int)(pixel &amp; 0x0000FF00) &gt;&gt; 8,
              (int)(pixel &amp; 0x00FF0000) &gt;&gt; 16);
  
      return color;
  } 
  </code></pre>
  
  <p>I'm getting the middle screen pixel like this: </p>
  
  <pre><code>int ScreenWidth = System.Windows.Forms.Screen.PrimaryScreen.Bounds.Width;
  int ScreenHeight = System.Windows.Forms.Screen.PrimaryScreen.Bounds.Height;
  </code></pre>
  
  <p>So how can I make this code compatible with full screen games?
  It gives me an ARGB value of <code>A = 255, R = 0, G = 0, B = 0</code>, even though I'm 100% positive that the middle screen pixel is RED.</p>