Translating System.Windows.Input.Key to VirtualKey?

Nov 2, 2010 at 7:19 PM

How can I translate a System.Windows.Input.Key event (received from a WPF Event Handler) into a VirtualKey that the Windows Input Simulator can send?

I am writing a simple remote control application that allows the user to pass mouse & keyboard events from one computer to the next.  I have the mouse actions working (thanks in part to this great library) but am having trouble with the key strokes due to the translation required.

Thanks for any help!

Mar 7, 2011 at 3:01 PM

There is a convertor in .NET 4:

VirtualKeyCode key = (VirtualKeyCode)KeyInterop.VirtualKeyFromKey(Key.Right);