/// <summary> /// 获取屏幕中鼠标所在位置的点的颜色值 /// </summary> /// <param name="ptr">获取的范围句柄设定(0为全屏幕)</param> /// <returns>返回颜色值</returns> public static Color GetMousePointColor(IntPtr ptr) { IntPtr hdc = WindowsAPI.GetDC(ptr); uint pixel = WindowsAPI.GetPixel(hdc, Cursor.Position.X, Cursor.Position.Y); WindowsAPI.ReleaseDC(IntPtr.Zero, hdc); Color color = Color.FromArgb((int)(pixel & 0x000000FF), (int)(pixel & 0x0000FF00) >> 8, (int)(pixel & 0x00FF0000) >> 16); return(color); }