Пример #1
0
        protected override void OnSourceInitialized(EventArgs e)
        {
            if (!(PresentationSource.FromVisual(this) is HwndSource source))
            {
                throw new InvalidOperationException("Cannot find a valid HwndSource");
            }

            _keyboardHwndSourceHook                    = new KeyboardHwndSourceHook(source, true);
            _keyboardHwndSourceHook.KeyPressed        += OnKeyPressed;
            _keyboardHwndSourceHook.InputDeviceChange += OnInputDeviceChange;

            _keyboardDevices = RawKeyboardDevice.GetDevices();

            DeviceCount = _keyboardDevices.Count;

            base.OnSourceInitialized(e);
        }
Пример #2
0
 private void OnInputDeviceChange(object sender, EventArgs e)
 {
     _keyboardDevices = RawKeyboardDevice.GetDevices();
 }