Forum Discussion
SendKeys on the WinKeys button
I have looked at MS's list of available send keys on their site, but they don't seem to have one listed for the actual Windows Key.
The only solution I found was....
SendKey.Send("^{ESC}")
However, the key strokes to show the desktop is Winkey+D
But, I can't seem to make using the ^{ESC} work with the letter "D"
SendKey.Send("^{ESC}(d)")
All I get is the Start menu popping up.
So, exactly how do I simulate "Winkey+D" with SendKeys???
Any input will be greatly appreciated
5 Replies
- LucasAndradeNetCopper Contributor
You can try this way, I had the same problem
[DllImport("user32.dll")] public static extern void keybd_event(byte bVk, byte bScan, uint dwFlags, uint dwExtraInfo); // Constantes para as teclas const byte VK_LWIN = 0x5B; const byte VK_D = 0x44; const int KEYEVENTF_KEYUP = 0x2; static void Main(string[] args) { keybd_event(VK_LWIN, 0, 0, 0); // Pressionar a tecla Windows keybd_event(VK_D, 0, 0, 0); // Pressionar a tecla D keybd_event(VK_D, 0, KEYEVENTF_KEYUP, 0); // Liberar a tecla D keybd_event(VK_LWIN, 0, KEYEVENTF_KEYUP, 0); // Liberar a tecla Windows Console.WriteLine("Tecla Windows + D simulada."); Console.ReadLine(); }
- Pixel-InkCopper ContributorOkay, No errors, but nothing else happens.
- LucasAndradeNetCopper Contributor
Pixel-Ink Try again with this code man
using System; using System.Diagnostics; class Program { static void Main(string[] args) { Process.Start("cmd", "/c rundll32.exe user32.dll,LockWorkStation"); Console.WriteLine("Press Enter to exit."); Console.ReadLine(); } }
This command is responsible for minimizing all open windows in the Windows operating system and showing the desktop.
When you run this code, the command will be called, and the action will be performed, simulating the press of the Windows + D key combination.
- Pixel-InkCopper Contributor