/*
键盘模拟器(用于模拟键盘发出指令)
*/
using System.Collections;
using System.Collections.Generic;
using System.Runtime.InteropServices;
namespace iFramework
{
public class KeyBoardSimulator
{
public enum OperateType
{
PressDown,
PressHoldOn,
PressRelease,
}
/// <summary>
/// byte bvk,//虚拟键值 ESC键对应的是27
/// byte bScan,//0
/// int dwFlags,//0为按下,1按住,2释放
/// int dwExtraInfo//0
/// </summary>
[DllImport("user32.dll", EntryPoint = "keybd_event")]
public static extern void Keybd_event(byte bvk, byte bScan, int dwFlags, int dwExtraInfo);
public static void SendMessage(OperateType type, byte KeyCode)
{
Keybd_event(KeyCode, 0, (int)type, 0);
}
///*
// 键盘键与虚拟键码对照表
// 字母和数字键 数字小键盘的键 功能键