2014-02-09 37 views
0

我想知道是否有方法可以從C#中的光標位置提取一些信息。從掃雷位置獲取信息在掃雷

我正在嘗試創建一個掃雷解算器,並希望將鼠標懸停在Windows版本的掃雷上,並能夠通過查看數字的顏色來查看周圍廣場的炸彈數量。

回答

-1

獲取使用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); 
0

您可以捕捉使用的答案提供給this other question代碼屏幕的位圖,但那麼你就必須來處理自己從中獲得任何意義。

+0

我還會捕獲鼠標的位置(P/Invoke)並在處理時利用這些信息。 – MasterMastic