GetAsyncKeyState VK_LBUTTON.名称在当前上下文中不存在

本文关键字:上下文 不存在 VK LBUTTON GetAsyncKeyState | 更新日期: 2023-09-27 18:08:41

    [DllImport("user32.dll")]
    public static extern short GetAsyncKeyState(UInt16 virtualKeyCode); 
    private void timer1_Tick(object sender, EventArgs e)
    {
        if (GetAsyncKeyState(VK_LBUTTON = 0x01))
        {
        }
    }
}

我一直得到一个错误说"名称'VK_LBUTTON'不存在于当前上下文中"。

GetAsyncKeyState VK_LBUTTON.名称在当前上下文中不存在

使用以下代码:

[DllImport("user32.dll")]
public static extern short GetAsyncKeyState(UInt16 virtualKeyCode);
private const UInt16 VK_MBUTTON = 0x04;//middle mouse button
private const UInt16 VK_LBUTTON = 0x01;//left mouse button
private const UInt16 VK_RBUTTON = 0x02;//right mouse button

查看更多详细信息http://msdn.microsoft.com/en-us/library/dd375731 (v = VS.85) . aspx