-1
[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」)] 公共靜態外部短GetAsyncKeyState(UINT16 virtualKeyCode); private const UInt16 VK_LBUTTON = 0x01; 私人無效timer1_Tick(對象發件人,EventArgs的) { 如果(GetAsyncKeyState(VK_LBUTTON))//這是突出顯示的錯誤 { MessageBox.Show( 「測試」); }} } } 和 它說: 「不能imlicitly轉換型 '短' 爲 '布爾'」 – Moe 2013-04-11 10:59:11
你可以這樣做,如果((布爾)GetAsyncKeyState(VK_LBUTTON)) – abhi294074 2013-04-11 11:12:47
作品。非常感謝!!! – Moe 2013-04-11 11:32:02