示例#1
0
 private static void pressKey(Win32Constants.VirtualKeys keys) {
     var input = new Win32Types.INPUT {
         Type = Win32Types.INPUTTYPE.INPUT_KEYBOARD,
         ki = {
             wVk = keys,
             dwFlags = Win32Constants.KeyboardEvent.KEYEVENTF_EXTENDEDKEY
         }
     };
     Win32Declares.KeyBoard.SendInput(1, new[] { input }, Win32Types.KEYBDINPUT.cbSize);
 }
示例#2
0
        public static void SendKeys(bool control, bool alt, bool shift, Win32Constants.VirtualKeys keys) {
            if (control)
                pressKey(Win32Constants.VirtualKeys.ControlLeft);
            if (alt)
                pressKey(Win32Constants.VirtualKeys.Menu);
            if (shift)
                pressKey(Win32Constants.VirtualKeys.ShiftLeft);

            sendKey(keys);

            if (control)
                releaseKey(Win32Constants.VirtualKeys.ControlLeft);
            if (alt)
                releaseKey(Win32Constants.VirtualKeys.Menu);
            if (shift)
                releaseKey(Win32Constants.VirtualKeys.ShiftLeft);

            Application.DoEvents();
        }
示例#3
0
 private static void sendKey(Win32Constants.VirtualKeys keys) {
     pressKey(keys);
     releaseKey(keys);
 }
 private static void SendKey(Win32Constants.VirtualKeys keys) {
     PressKey(keys);
     ReleaseKey(keys);
 }