CTRL+ESC
不模擬WIN
鍵,它只是調用開始菜單。
的P/Invoke的一點總是讓每個人都高興:
using System.Runtime.InteropServices;
using System.Windows.Forms;
static class KeyboardSend
{
[DllImport("user32.dll")]
private static extern void keybd_event(byte bVk, byte bScan, int dwFlags, int dwExtraInfo);
private const int KEYEVENTF_EXTENDEDKEY = 1;
private const int KEYEVENTF_KEYUP = 2;
public static void KeyDown(Keys vKey)
{
keybd_event((byte)vKey, 0, KEYEVENTF_EXTENDEDKEY, 0);
}
public static void KeyUp(Keys vKey)
{
keybd_event((byte)vKey, 0, KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP, 0);
}
}
你這樣調用它:
KeyboardSend.KeyDown(Keys.LWin);
KeyboardSend.KeyDown(Keys.D4);
KeyboardSend.KeyUp(Keys.LWin);
KeyboardSend.KeyUp(Keys.D4);
測試,它的工作原理。玩的開心!
謝謝!您在示例中使用了WinKey + 4。要將其更改爲WinKey + 1,只需將Keys.D4更改爲Keys.D1即可。 再次感謝! :) – demijnzia