using System.Runtime.InteropServices;
using Systehttp://m.Windows.Forms;
static class KeyboardSend
{
[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);
}
}
KeyboardSend.KeyDown(Keys.LWin);
KeyboardSend.KeyDown(Keys.D4);
KeyboardSend.KeyUp(Keys.LWin);
KeyboardSend.KeyUp(Keys.D4);
[출처] C# SendKeys를 사용하여 프로그래밍 방식으로 Windows 키를 누르는 방법|작성자 jeren914144
Environment.GetFolderPath() (0) | 2024.08.19 |
---|---|
OpenCV4 바코드 리딩 (0) | 2024.06.20 |
HTTP/HTTPS 송수신 (HttpWebRequest/HttpWebResponse) (0) | 2021.08.24 |
C# 배포시 난독화를 해야 할까? - ConfuserEx 사용법 (0) | 2021.01.06 |
c# Task 7가지 사용법 (0) | 2021.01.04 |