private bool IsRepeatKey(uint vk, uint scan, Win32.WindowHook.LLKHF flags, uint time) { bool keyIsPressed = pressedKeys[vk] == 0x80; if (Win32.WindowHook.LLKHF.UP != (flags & Win32.WindowHook.LLKHF.UP)) { if (keyIsPressed) { return(true); } else { this.pressedKeys[vk] = 0x80; } } else { if (!keyIsPressed) { return(true); } else { this.pressedKeys[vk] = (byte)(Win32.IsToggled((Win32.VK)vk) ? 1 : 0); } } return(false); }
private void OnKeyboardEventViaViq(uint vk, Win32.WindowHook.LLKHF flags, uint scan, uint time, Win32.CAS cas) { int wParam = (int)vk; Win32.WM wm = (((flags & Win32.WindowHook.LLKHF.UP) == Win32.WindowHook.LLKHF.UP) ? Win32.WM.KEYUP : Win32.WM.KEYDOWN); // TODO SYSKEYDOWN via Win32.WindowHook.LLKHF.AltKey ? uint lParam = 0x01; if (wm == Win32.WM.KEYUP) { lParam |= 0xC0000000; } uint scanCode = scan; if (scanCode > 0) { lParam |= ((scanCode & 0xFF) << 16); } if ((flags & Win32.WindowHook.LLKHF.UP) != Win32.WindowHook.LLKHF.UP) { if ((cas & Win32.CAS.CONTROL) != 0) { OnKeyboardEventViaViq((uint)Win32.VK.Control, (Win32.WindowHook.LLKHF) 0, (uint)0, time, (Win32.CAS) 0); } if ((cas & Win32.CAS.ALT) != 0) { OnKeyboardEventViaViq((uint)Win32.VK.Menu, (Win32.WindowHook.LLKHF) 0, (uint)0, time, (Win32.CAS) 0); flags |= Win32.WindowHook.LLKHF.ALTDOWN; } if ((cas & Win32.CAS.SHIFT) != 0) { OnKeyboardEventViaViq((uint)Win32.VK.Shift, (Win32.WindowHook.LLKHF) 0, (uint)0, time, (Win32.CAS) 0); } } Win32.SetKeyboardState(this.pressedKeys); Win32.Windows.SendMessage(WindowHandle, wm, wParam, lParam); // if keydown, translate message if (wm == Win32.WM.KEYDOWN) { Mubox.Win32.Windows.MSG msg = new Win32.Windows.MSG(); msg.hwnd = WindowHandle; msg.lParam = lParam; msg.message = wm; msg.pt = new Win32.Windows.POINT(); msg.time = Win32.SendInputApi.GetTickCount(); msg.wParam = (int)vk; Win32.Windows.TranslateMessage(ref msg); } if ((flags & Win32.WindowHook.LLKHF.UP) != Win32.WindowHook.LLKHF.UP) { if ((cas & Win32.CAS.CONTROL) != 0) { OnKeyboardEventViaViq((uint)Win32.VK.Control, Win32.WindowHook.LLKHF.UP, (uint)0, Win32.SendInputApi.GetTickCount(), (Win32.CAS) 0); } if ((cas & Win32.CAS.ALT) != 0) { OnKeyboardEventViaViq((uint)Win32.VK.Menu, Win32.WindowHook.LLKHF.UP, (uint)0, Win32.SendInputApi.GetTickCount(), (Win32.CAS) 0); } if ((cas & Win32.CAS.SHIFT) != 0) { OnKeyboardEventViaViq((uint)Win32.VK.Shift, Win32.WindowHook.LLKHF.UP, (uint)0, Win32.SendInputApi.GetTickCount(), (Win32.CAS) 0); } } }