Last active
September 8, 2018 06:21
-
-
Save Misaka-0x447f/1e11d74c7a54c6f5a8420ff9aea954e9 to your computer and use it in GitHub Desktop.
Press LWIN key in C#
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public partial class Form1 : Form | |
{ | |
[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); | |
} | |
public Form1() | |
{ | |
InitializeComponent(); | |
} | |
private void button1_Click(object sender, EventArgs e) { | |
KeyDown(Keys.LWin); | |
KeyUp(Keys.LWin); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Start.zip