private void ProcessRawInput(IntPtr wParam) { RAWINPUT rawInput = new RAWINPUT(); int length = Marshal.SizeOf(typeof(RAWINPUT)); int result = GetRawInputData(wParam, RawInputCommand.Input, out rawInput, ref length, Marshal.SizeOf(typeof(RAWINPUTHEADER))); if (result != 1) { if (rawInput.Header.Type == RawInputType.Keyboard) { if ((rawInput.Keyboard.Flags == 0)) { RawInputEvent(new RawInputEventArgs(rawInput.Keyboard.VirtualKey, false)); } if ((rawInput.Keyboard.Flags & 1) != 0) { RawInputEvent(new RawInputEventArgs(rawInput.Keyboard.VirtualKey, true)); } } } }
private static extern int GetRawInputData(IntPtr hRawInput, RawInputCommand uiCommand, out RAWINPUT pData, ref int pcbSize, int cbSizeHeader);