Ejemplo n.º 1
0
        /// <summary>
        /// 模拟鼠标弹出
        /// </summary>
        /// <param name="vKeyCoad"></param>
        public void ImitageMouseUp(int vKeyCoad)
        {
            int btScancode = 0;

            btScancode = Windows32API.MapVirtualKey((byte)vKeyCoad, 0);
            // btScancode = vKeyCoad;

            KBCWait4IBE();                                                         // '发送数据前应该先等待键盘缓冲区为空
            Windows32API.SetPortVal(KBC_KEY_CMD, (IntPtr)0xD3, 1);                 //'发送键盘写入命令
            KBCWait4IBE();
            Windows32API.SetPortVal(KBC_KEY_DATA, (IntPtr)(btScancode | 0x80), 1); // '写入按键信息,释放键
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 模拟鼠标按下
        /// </summary>
        /// <param name="vKeyCoad"></param>
        public void ImitageMouseDown(int vKeyCoad)
        {
            int btScancode = 0;

            btScancode = Windows32API.MapVirtualKey((byte)vKeyCoad, 0);
            //btScancode = vKeyCoad;

            KBCWait4IBE();                                         // '发送数据前应该先等待键盘缓冲区为空
            Windows32API.SetPortVal(KBC_KEY_CMD, (IntPtr)0xD3, 1); // '发送键盘写入命令
            //SetPortVal函数用于向端口写入数据,它的用法是SetPortVal 端口号,欲写入的数据,写入数据的长度
            KBCWait4IBE();
            Windows32API.SetPortVal(KBC_KEY_DATA, (IntPtr)(btScancode | 0x80), 1);// '写入按键信息,按下键
        }