我想知道是否有一种方法可以让我从C#中的光标位置提取一些信息。
我正在尝试创建一个扫雷解算器,希望鼠标悬停在windows版本的扫雷程序上,并能够通过查看数字的颜色来辨别方块周围的炸弹数量。
发布于 2014-02-09 17:51:27
您可以使用answers to this other question中提供的代码来捕获屏幕的位图,但是您必须自己处理该位图才能从中获得任何含义。
发布于 2014-02-09 17:11:36
使用Windows API获取光标位置:
using System.Runtime.InteropServices;
[DllImport("user32.dll")]
public static extern bool GetCursorPos(out POINT lpPoint);
[StructLayout(LayoutKind.Sequential)]
public struct POINT
{
public int X;
public int Y;
public static implicit operator Point(POINT point)
{
return new Point(point.X, point.Y);
}
}
POINT lpPoint;
// Get current location of cursor
GetCursorPos( out lpPoint );https://stackoverflow.com/questions/21654237
复制相似问题