主要原理就是將屏幕全圖抓屏,然後獲取鼠標當前位置,取色。直接看代碼:
1 using System;
2 using System.Collections.Generic;
3 using System.ComponentModel;
4 using System.Data;
5 using System.Drawing;
6 using System.Linq;
7 using System.Text;
8 using System.Windows.Forms;
9 using System.Runtime.InteropServices;
10
11 namespace GetScrColor
12 {
13 public partial class Form1 : Form
14 {
15 public Form1()
16 {
17 InitializeComponent();
18 }
19
20 private bool flag = false;
21
22 public struct POINTAPI
23 {
24 public uint x;
25 public uint y;
26 }
27
28 public class WinInfo
29 {
30 [DllImport("user32.dll")]
31 public static extern uint WindowFromPoint
32 (
33 uint x_point,
34 uint y_point
35 );
36
37 [DllImport("user32.dll")]