1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
|
public static void PressKey(IntPtr hWindow, System.Windows.Input.Key key, bool shift, bool maj, bool control, bool alt, bool altGr)
{
if (altGr)
DLLImports.keybd_event((byte)System.Windows.Input.KeyInterop.VirtualKeyFromKey(Key.RightAlt), (int)Key.RightAlt, Constantes.KEYEVENTF_EXTENDEDKEY | 0, (UIntPtr)0);
if (alt)
DLLImports.keybd_event((byte)System.Windows.Input.KeyInterop.VirtualKeyFromKey(Key.LeftAlt), (int)Key.LeftAlt, Constantes.KEYEVENTF_EXTENDEDKEY | 0, (UIntPtr)0);
if (control)
DLLImports.keybd_event((byte)System.Windows.Input.KeyInterop.VirtualKeyFromKey(Key.RightCtrl), (int)Key.RightCtrl, Constantes.KEYEVENTF_EXTENDEDKEY | 0, (UIntPtr)0);
if (shift || maj)
DLLImports.keybd_event((byte)System.Windows.Input.KeyInterop.VirtualKeyFromKey(Key.RightShift), (int)Key.RightShift, Constantes.KEYEVENTF_EXTENDEDKEY | 0, (UIntPtr)0);
DLLImports.keybd_event((byte)System.Windows.Input.KeyInterop.VirtualKeyFromKey(key), (int)Key.RightShift, Constantes.KEYEVENTF_EXTENDEDKEY | 0, (UIntPtr)0);
if (shift || maj)
DLLImports.keybd_event((byte)System.Windows.Input.KeyInterop.VirtualKeyFromKey(Key.RightShift), (int)Key.RightShift, Constantes.KEYEVENTF_EXTENDEDKEY | Constantes.KEYEVENTF_KEYUP, (UIntPtr)0);
if (control)
DLLImports.keybd_event((byte)System.Windows.Input.KeyInterop.VirtualKeyFromKey(Key.RightCtrl), (int)Key.RightCtrl, Constantes.KEYEVENTF_EXTENDEDKEY | Constantes.KEYEVENTF_KEYUP, (UIntPtr)0);
if (alt)
DLLImports.keybd_event((byte)System.Windows.Input.KeyInterop.VirtualKeyFromKey(Key.LeftAlt), (int)Key.LeftAlt, Constantes.KEYEVENTF_EXTENDEDKEY | Constantes.KEYEVENTF_KEYUP, (UIntPtr)0);
if (altGr)
DLLImports.keybd_event((byte)System.Windows.Input.KeyInterop.VirtualKeyFromKey(Key.RightAlt), (int)Key.RightAlt, Constantes.KEYEVENTF_EXTENDEDKEY | Constantes.KEYEVENTF_KEYUP, (UIntPtr)0);
} |
Partager