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,236
  • 14
  • 55
  • 90
Kelsey Abreu
  • 1,034
  • 3
  • 17
  • 40

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
  • 14,952
  • 2
  • 28
  • 54
-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,055
  • 2
  • 15
  • 28