📜  如何在c#代码示例中检测鼠标点击

📅  最后修改于: 2022-03-11 14:48:59.478000             🧑  作者: Mango

代码示例1
[DllImport("user32.dll")]
static extern short GetAsyncKeyState(int VirtualKeyPressed);
 
public static bool GetLeftMousePressed()
    {
        if (GetAsyncKeyState(0x01) == 0)
            return false;
        else
            return true;
    }

// 0x01 stands for left Mouse click
// for different Virtual-Keys view list:
// https://docs.microsoft.com/en-us/windows/win32/inputdev/virtual-key-codes

Credit: Jason Wong on Stack Overflow