示例#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));
        }
示例#2
0
 internal static extern bool PeekConsoleInput(IntPtr hConsoleInput, out InputRecord buffer, int numInputRecords_UseOne, out int numEventsRead);
示例#3
0
 extern static bool ReadConsoleInput(IntPtr handle, out InputRecord record, int length, out int nread);
示例#4
0
 extern static bool PeekConsoleInput(IntPtr handle, out InputRecord record, int length, out int eventsRead);
		extern static bool PeekConsoleInput (IntPtr handle, out InputRecord record, int length, out int eventsRead);
		extern static bool ReadConsoleInput (IntPtr handle, out InputRecord record, int length, out int nread);
		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();
		}
示例#9
0
 static bool PeekConsoleInput(IntPtr handle, out InputRecord record, int length, out int eventsRead)
 {
     throw new System.NotImplementedException();
 }
示例#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