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

前端 未结 5 1762
野趣味
野趣味 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:11

    Similar to Bill Tarbell's answer, you can also create a dummy System.Windows.Interop.HwndSource, like so:

    var kea = new KeyEventArgs(
        Keyboard.PrimaryDevice, 
        new HwndSource(0, 0, 0, 0, 0, "", IntPtr.Zero), // dummy source
        0, 
        key);
    

提交回复
热议问题