How to create a KeyEventArgs object in WPF ( related to a SO answer )

前端 未结 5 1773
野趣味
野趣味 2020-12-29 04:39

I\'ve found this answer which look like what I need:

How can I programmatically generate keypress events in C#?

Except for the fact I can\'t create an insta

5条回答
  •  太阳男子
    2020-12-29 05:05

    phewwww

    I've found it: Keyboard.PrimaryDevice.ActiveSource has to be used

    InputManager.Current.ProcessInput(
        new KeyEventArgs(Keyboard.PrimaryDevice,
            Keyboard.PrimaryDevice.ActiveSource,
            0, Key.Tab)
        {
           RoutedEvent = Keyboard.KeyDownEvent
        }
    );
    

提交回复
热议问题