[c#] Sending Windows key using SendKeys

I am working on shortcuts in C#. I succeed implementing Ctrl, Alt and Shift with SendKeys.

Like this;

Ctrl + C:

System.Windows.Forms.SendKeys.SendWait("^c");

or Alt + F4:

System.Windows.Forms.SendKeys.SendWait("%{F4}");

But I can't send "Windows Key" with SendKeys. I tried ex: Win + E : .SendWait("#e") but it's not working. What should I use instead of "#"?

Thanks.

This question is related to c# keyboard-shortcuts sendkeys

The answer is


Alt+F4 is working only in brackets

SendKeys.SendWait("(%{F4})");

download InputSimulator from nuget package.

then write this:

        var simu = new InputSimulator();
        simu.Keyboard.ModifiedKeyStroke(VirtualKeyCode.LWIN, VirtualKeyCode.VK_E);

in my case to create new vertial desktop, 3 keys needed and code like this(windows key + ctrl + D):

        simu.Keyboard.ModifiedKeyStroke(new[] { VirtualKeyCode.LWIN, VirtualKeyCode.CONTROL }, VirtualKeyCode.VK_D);

SetForegroundWindow( /* window to gain focus */ );
SendKeys.SendWait("^{ESC}"); // ^{ESC} is code for ctrl + esc which mimics the windows key.