0

I'm wondering if there is a way for me to extract some information from a cursor position in C#.

I'm trying to create a minesweeper solver and would like for the mouse to hover over the windows version of Minesweeper and be able to tell the amount of bombs surrounding a square by looking at the color of the number.

Ondrej Janacek
  • 12,486
  • 14
  • 59
  • 93
Kelsey Abreu
  • 1,094
  • 3
  • 17
  • 42

2 Answers2

0

You can capture a bitmap of the screen using the code provided in answers to this other question but you'll then have to process that yourself to derive any meaning from it.

Community
  • 1
  • 1
Mark Feldman
  • 15,731
  • 3
  • 31
  • 58
-1

Getting cursor location using 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 );
Mustafa Chelik
  • 2,113
  • 2
  • 17
  • 29