title: Trigger a keyboard key press event without pressing the key from keyboard
body: <p>How can I trigger a key press event without pressing the key from Keyboard? I tried with the solution from <a href="https://stackoverflow.com/questions/1645815/how-can-i-programmatically-generate-keypress-events-in-c">here</a>, but I got the following exception: </p>
  
  <blockquote>
    <p>The best overloaded method match for
    'System.Windows.PresentationSource.FromVisual(System.Windows.Media.Visual)'
    has some invalid arguments.</p>
  </blockquote>
  
  <p>Consider <kbd>Shift+A</kbd> contains 2 key press event from keyboard,how can I do it without keyboard pressing?(let, just print capital A in a textbox on a button click)  </p>
  
  <p><strong>My code</strong></p>
  
  <pre><code>var key = Key.A;                    // Key to send
  var target = Keyboard.FocusedElement;    // Target element
  var routedEvent = Keyboard.KeyDownEvent; // Event to send
  
  target.RaiseEvent(new System.Windows.Input.KeyEventArgs(Keyboard.PrimaryDevice, System.Windows.PresentationSource.FromVisual(target), 0, key) { RoutedEvent = routedEvent });
  </code></pre>