Exemplo n.º 1
0
        /// <summary>
        ///     Writes a char to the started processes InputStream.
        /// </summary>
        public bool Write(char c, bool Ctrl, bool Shift, bool Alt)
        {
            uint CtrlKeyState = 0;

            #region Apply modifiers
            if (Ctrl)
            {
                CtrlKeyState |= (uint)Win32.ControlKeyState.LEFT_CTRL_PRESSED;
            }
            if (Alt)
            {
                CtrlKeyState |= (uint)Win32.ControlKeyState.LEFT_ALT_PRESSED;
            }
            if (Shift)
            {
                CtrlKeyState |= (uint)Win32.ControlKeyState.SHIFT_PRESSED;
            }
            #endregion

            Win32.INPUT_RECORD[] input = new Win32.INPUT_RECORD[2];
            input[0].EventType                  = (ushort)Win32.EventTypes.KEY;
            input[0].KeyEvent.bKeyDown          = true;
            input[0].KeyEvent.dwControlKeyState = CtrlKeyState;
            input[0].KeyEvent.UnicodeChar       = c;
            // input[0].KeyEvent.wVirtualKeyCode = (uint)key;
            input[0].KeyEvent.wRepeatCount = 1;

            input[1].EventType = (ushort)Win32.EventTypes.KEY;
            input[1].KeyEvent.dwControlKeyState = CtrlKeyState;
            input[1].KeyEvent.UnicodeChar       = c;
            input[1].KeyEvent.wRepeatCount      = 1;
            // input[1].KeyEvent.wVirtualKeyCode = (uint)key;
            input[1].KeyEvent.bKeyDown = false;

            uint events_written;
            return(Win32.WriteConsoleInput(this.readHndl, input, (uint)input.Length, out events_written));
        }
Exemplo n.º 2
0
        /// <summary>
        ///     Writes a char to the started processes InputStream.
        /// </summary>
        public bool Write(char c, bool Ctrl, bool Shift, bool Alt)
        {
            uint CtrlKeyState = 0;
            #region Apply modifiers
            if (Ctrl)
                CtrlKeyState |= (uint)Win32.ControlKeyState.LEFT_CTRL_PRESSED;
            if (Alt)
                CtrlKeyState |= (uint)Win32.ControlKeyState.LEFT_ALT_PRESSED;
            if (Shift)
                CtrlKeyState |= (uint)Win32.ControlKeyState.SHIFT_PRESSED;
            #endregion

            Win32.INPUT_RECORD[] input = new Win32.INPUT_RECORD[2];
            input[0].EventType = (ushort)Win32.EventTypes.KEY;
            input[0].KeyEvent.bKeyDown = true;
            input[0].KeyEvent.dwControlKeyState = CtrlKeyState;
            input[0].KeyEvent.UnicodeChar = c;
            // input[0].KeyEvent.wVirtualKeyCode = (uint)key;
            input[0].KeyEvent.wRepeatCount = 1;

            input[1].EventType = (ushort)Win32.EventTypes.KEY;
            input[1].KeyEvent.dwControlKeyState = CtrlKeyState;
            input[1].KeyEvent.UnicodeChar = c;
            input[1].KeyEvent.wRepeatCount = 1;
            // input[1].KeyEvent.wVirtualKeyCode = (uint)key;
            input[1].KeyEvent.bKeyDown = false;

            uint events_written;
            return Win32.WriteConsoleInput(this.readHndl, input, (uint)input.Length, out events_written);
        }