Ejemplo n.º 1
0
        public ConsoleKeyInfo ReadKey(bool intercept)
        {
            int         eventsRead;
            InputRecord record = new InputRecord();

            do
            {
                if (!ReadConsoleInput(inputHandle, out record, 1, out eventsRead))
                {
                    throw new InvalidOperationException("Error in ReadConsoleInput " +
                                                        Marshal.GetLastWin32Error());
                }
            } while (record.EventType != 1 && !record.KeyDown);

            // RIGHT_ALT_PRESSED 1
            // LEFT_ALT_PRESSED 2
            // RIGHT_CTRL_PRESSED 4
            // LEFT_CTRL_PRESSED 8
            // SHIFT_PRESSED 16
            bool alt   = ((record.ControlKeyState & 3) != 0);
            bool ctrl  = ((record.ControlKeyState & 12) != 0);
            bool shift = ((record.ControlKeyState & 16) != 0);

            return(new ConsoleKeyInfo(record.Character, (ConsoleKey)record.VirtualKeyCode, shift, alt, ctrl));
        }
Ejemplo n.º 2
0
 internal static extern bool PeekConsoleInput(IntPtr hConsoleInput, out InputRecord buffer, int numInputRecords_UseOne, out int numEventsRead);
Ejemplo n.º 3
0
 extern static bool ReadConsoleInput(IntPtr handle, out InputRecord record, int length, out int nread);
Ejemplo n.º 4
0
 extern static bool PeekConsoleInput(IntPtr handle, out InputRecord record, int length, out int eventsRead);
Ejemplo n.º 5
0
		extern static bool PeekConsoleInput (IntPtr handle, out InputRecord record, int length, out int eventsRead);
Ejemplo n.º 6
0
		extern static bool ReadConsoleInput (IntPtr handle, out InputRecord record, int length, out int nread);
Ejemplo n.º 7
0
		public ConsoleKeyInfo ReadKey (bool intercept)
		{
			int eventsRead;
			InputRecord record = new InputRecord ();
			for (;;) {
				if (!ReadConsoleInput (inputHandle, out record, 1, out eventsRead))
					throw new InvalidOperationException ("Error in ReadConsoleInput " +
									Marshal.GetLastWin32Error ());
				if (record.KeyDown && record.EventType == 1 && !IsModifierKey (record.VirtualKeyCode))
					break;
			}

			// RIGHT_ALT_PRESSED 1
			// LEFT_ALT_PRESSED 2
			// RIGHT_CTRL_PRESSED 4
			// LEFT_CTRL_PRESSED 8
			// SHIFT_PRESSED 16
			bool alt = ((record.ControlKeyState & 3) != 0);
			bool ctrl = ((record.ControlKeyState & 12) != 0);
			bool shift = ((record.ControlKeyState & 16) != 0);
			return new ConsoleKeyInfo (record.Character, (ConsoleKey) record.VirtualKeyCode, shift, alt, ctrl);
		}
		static bool ReadConsoleInput (IntPtr handle, out InputRecord record, int length, out int nread)
		{
			throw new System.NotImplementedException();
		}
Ejemplo n.º 9
0
 static bool PeekConsoleInput(IntPtr handle, out InputRecord record, int length, out int eventsRead)
 {
     throw new System.NotImplementedException();
 }
Ejemplo n.º 10
0
		internal static extern bool WriteConsoleInput(
			IntPtr hConsoleInput,
			InputRecord[] lpBuffer,
			uint nLength,
			out uint lpNumberOfEventsWritten);
 private static extern bool GetConsoleScreenBufferInfo(IntPtr handle, out ConsoleScreenBufferInfo info);        // 0x0000000180A78170-0x0000000180A78210
 private static extern bool ReadConsoleInput(IntPtr handle, out InputRecord record, int length, out int nread); // 0x0000000180A782D0-0x0000000180A783E0