如何模拟按键

  public const byte VK_NONAME = 0xFC; // 什么也不做
        public const byte VK_ESC = 0x1B; // Smartphone的回退键
        public const byte VK_F4 = 0x73; // Home Screen
        public const byte VK_APP6 = 0xC6; // Smartphone上锁定键盘
        public const byte VK_F22 = 0x85; // PocketPC上锁定键盘(VK_KEYLOCK)
        public const byte VK_F16 = 0x7F; // 出发扬声器
        public const byte VK_OFF = 0x7F; //电源键
        public const byte VK_TSOFT1 = 0x70;
        public const byte VK_TSOFT2 = 0x71;
        public const byte VK_TTALK = 0x72;
        public const byte VK_TEND = 0x73;

  /// <summary>
        /// 将按键送至全局键盘缓冲区
        /// </summary>
        /// <param name="key"></param>

        public static void SendKey(byte key)
        {
            //const byte KEYEVENTF_SILENT = 0x0004;
            const int KEYEVENTF_KEYUP = 0x02;
            const int KEYEVENTF_KEYDOWN = 0x00;
            keybd_event(key, 0, KEYEVENTF_KEYDOWN, 0);
            keybd_event(key, 0, KEYEVENTF_KEYUP, 0);
        }

        [DllImport("coredll", SetLastError = true)]
        private static extern void keybd_event(byte bVk, byte bScan, int dwFlags, int dwExtraInfo);

 private void button1_Click(object sender, EventArgs e)
        {
            SendKey(VK_TTALK);
        }

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值