using System;
using System.Drawing;
using System.Runtime.InteropServices;
namespace cs
{
public class cs
{
[DllImport("user32", ExactSpelling = true, CharSet = CharSet.Ansi, SetLastError = true)]
private static extern int WindowFromPoint(int xPoint, int yPoint);
//指定点窗口的句柄
[DllImport("user32", ExactSpelling = true, CharSet = CharSet.Ansi, SetLastError = true)]
private static extern int GetDC(int hwnd);
//获取屏幕DC(这个咧自己想的)
[DllImport("gdi32", ExactSpelling = true, CharSet = CharSet.Ansi, SetLastError = true)]
private static extern int GetPixel(int hdc, int X, int y);
//获取屏幕指定点的颜色
public Color GetColor(int x, int y)
{
int hdc = GetDC(IntPtr .Zero );
uint pixel = GetPixel(hdc, x, y);
ReleaseDC(IntPtr.Zero, hdc);
Color color = Color.FromArgb((int)(pixel & 0x000000FF), (int)(pixel & 0x0000FF00) >> 8, (int)(pixel & 0x00FF0000) >> 16);
return color;
}
public static void Main()
{
Console.ReadKey ();
}
}
请帮我写全这段代码,我自己写了N久,还是没搞清楚怎么用这个函数