Exemple #1
0
        /// <summary>
        /// Reads characters from the screen buffer, starting at the given position.
        /// </summary>
        /// <param name="nChars">The number of characters to read.</param>
        /// <param name="x">Column position of the first character to read.</param>
        /// <param name="y">Row position of the first character to read.</param>
        /// <returns>A string containing the characters read from the screen buffer.</returns>
        public string ReadXY(int nChars, int x, int y)
        {
            if (disposed)
            {
                throw new ObjectDisposedException(this.ToString());
            }
            char[] buff      = new char[nChars];
            int    charsRead = 0;

            if (!WinCon.ReadConsoleOutputCharacter(_handle, buff, nChars,
                                                   new Coord((short)x, (short)y), ref charsRead))
            {
                throw new System.IO.IOException("Read error", Marshal.GetLastWin32Error());
            }
            return(new string(buff, 0, charsRead));
        }