0
    [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’”。任何帮助将非常感激。

4

1 回答 1

1

使用以下代码。

[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

于 2013-04-11T09:08:36.013 回答