Forum Discussion
Pixel-Ink
Jun 20, 2023Copper Contributor
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}") H...
LucasAndradeNet
Jun 23, 2023Copper 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-InkJun 25, 2023Copper ContributorOkay, No errors, but nothing else happens.
- LucasAndradeNetJun 26, 2023Copper 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-InkJun 26, 2023Copper ContributorThanks, I already can do it this way.
- Pixel-InkJun 23, 2023Copper Contributor