private void Initialize() { if (WinIoApi.InitializeWinIo()) { KbcWait4Ibe(); } }
/// <summary> /// 等待键盘缓冲区为空 /// </summary> private void KbcWait4Ibe() { int dwVal; do { WinIoApi.GetPortVal((IntPtr)0x64, out dwVal, 1); }while ((dwVal & 0x2) > 0); }
/// <summary> /// 模拟键盘弹出 /// </summary> /// <param name="vKeyCoad"></param> public void KeyUp(Keys vKeyCoad) { var btScancode = User32Api.MapVirtualKey((uint)vKeyCoad, 0); KbcWait4Ibe(); WinIoApi.SetPortVal(WinIoApi.KbcKeyCmd, (IntPtr)0xD2, 1); KbcWait4Ibe(); WinIoApi.SetPortVal(WinIoApi.KbcKeyData, (IntPtr)0x60, 1); KbcWait4Ibe(); WinIoApi.SetPortVal(WinIoApi.KbcKeyCmd, (IntPtr)0xD2, 1); KbcWait4Ibe(); WinIoApi.SetPortVal(WinIoApi.KbcKeyData, (IntPtr)(btScancode | 0x80), 1); }
public void Shutdown() { WinIoApi.ShutdownWinIo(); }