我的目标:
我的难度
我当前的代码:
public static Color RetrieveColour(Point Coordinates)
{
//Use this 'image' to create a Graphics class.
using (Graphics Destination = Graphics.FromImage(ScreenPixel))
{
//Creates a graphic from the specified handler to a window.
//In this case, it uses a handler which has been initialised to zero.
using (Graphics Source = Graphics.FromHwnd(IntPtr.Zero))
{
//Handler from the source device context.
IntPtr HandlerSourceDC = Source.GetHdc();
//Handler to the destination device context.
IntPtr HandlerDC = Destination.GetHdc();
//BitBlt is responsible for doing the copying.
//Returns a non-zero value for upon success.
int retval = BitBlt(HandlerDC, 0, 0, 1, 1, HandlerSourceDC, Coordinates.X, Coordinates.Y, (int)CopyPixelOperation.SourceCopy);
//Release the handlers.
Destination.ReleaseHdc();
Source.ReleaseHdc();
}
}
//Retrieve the colour of the pixel at the specified coordinates.
return ScreenPixel.GetPixel(0, 0);
}
我应该补充一点,它应该适用于非Windows游标。我的意思是来自其他应用程序的自定义游标(如果这与未来的答案有关)。
答案 0 :(得分:1)
据我所知,您能够做到这一点的唯一方法是创建一个可以充当用户之间中介的自定义驱动程序。
我没有读过太多内容,但你可能想看一下这个项目 http://www.codeproject.com/KB/cs/DesktopCaptureWithMouse.aspx?display=Print