0

I want to send a string to textbox using a button click on wpf... Does anyone knows how to use inputmanager because the code below wont work? I use the code to test to send a delete or a letter a to a textbox...

public static class SendKeys
  {
    /// <summary>
    ///   Sends the specified key.
    /// </summary>
    /// <param name="key">The key.</param>
    public static void Send(Key key)
    {
      if (Keyboard.PrimaryDevice != null)
      {
        if (Keyboard.PrimaryDevice.ActiveSource != null)
        {
          var e1 = new KeyEventArgs(Keyboard.PrimaryDevice, Keyboard.PrimaryDevice.ActiveSource, 0, Key.Down) {RoutedEvent = Keyboard.KeyDownEvent};
          InputManager.Current.ProcessInput(e1);
        }
      }
    }
  }
jack
  • 1
  • 4
  • Does this answer your question? [How can I programmatically generate keypress events in C#?](https://stackoverflow.com/questions/1645815/how-can-i-programmatically-generate-keypress-events-in-c) – Marlonchosky Apr 19 '20 at 17:21
  • ok thanks ill try... – jack Apr 19 '20 at 17:42

0 Answers0