如何用 C# 打开第二个 Window 选择菜单(Start+P)?

How to open 2nd Window Selection menu(Start+P) with C#?

如标题所说一切都清楚。我想通过我的 Windows 应用程序打开此菜单。谢谢

使用如下代码 post:

SendKeys.Send and Windows Key

发送您的 Windows+P 击键。

使用以下代码:

    private void button1_Click(object sender, EventArgs e)
    {
        KeyDown(ConsoleKey.LeftWindows);
        KeyDown(ConsoleKey.P);
        KeyUp(ConsoleKey.LeftWindows);
        KeyUp(ConsoleKey.P);
    }

    [System.Runtime.InteropServices.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(ConsoleKey vKey)
    {
        keybd_event((byte)vKey, 0, KEYEVENTF_EXTENDEDKEY, 0);
    }
    public static void KeyUp(ConsoleKey vKey)
    {
        keybd_event((byte)vKey, 0, KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP, 0);
    }