如何读取不在前台的应用程序的屏幕像素?

我目前的代码非常适合读取屏幕上显示的任何像素颜色,其摘录如下所示:

using (Bitmap bmpScreenCapture = new Bitmap(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height)) { using (Graphics g = Graphics.FromImage(bmpScreenCapture)) { g.CopyFromScreen(Screen.PrimaryScreen.Bounds.X, Screen.PrimaryScreen.Bounds.Y, 0, 0, bmpScreenCapture.Size, CopyPixelOperation.SourceCopy); } Color c = bmpScreenCapture.GetPixel(x,y); } 

但是,要使其正常工作,我正在检查的窗口必须是屏幕上显示的内容。 如果我将另一个窗口带到前台,那么我的代码不起作用,因为它当然是在监视屏幕像素。

我怎样才能使我的代码可以继续读取与我想要监视的程序相关联的顶部窗口的像素,当它的窗口位于其他窗口后面时? 谢谢。