Thread: how do I copy characters from the Console window verbatim?

  1. #1
    Registered User
    Join Date
    Sep 2011
    Posts
    71

    how do I copy characters from the Console window verbatim?

    I used the Console's CursorLeft and CursorTop properties to specify the exact areas of the screen where I wanted to print information. I ended up with a 'table' full of data.

    Then I used the System.Diagnostics.Trace class and added a TextWriterTraceListener and a ConsoleTraceListener object to its Listeners collection.

    Then I replaced all the instances of Console.Write with Trace.Write.

    The data displayed as expected on the console. But on the text file the info was printed in the same order the info was outputted to the Console. ie: all the characters used to separate rows lumped together, followed by all the characters used to separate columns lumped together, followed by the actual data that was printed between those characters, all lumped together.

    I can see why I ended up with this mess. The TextWriter is oblivious of the fact that the Console's cursor position was arbitrarily modified by the application code before and after each character and piece of data was printed to the Console.

    Is there a way I can just grab the text that was printed to the console, ignoring the actual order in which the individual characters were printed, and save it as a string or directly print it to a file exactly as-it-is?
    Last edited by y99q; 12-17-2011 at 02:11 AM.

  2. #2
    Registered User
    Join Date
    Sep 2011
    Posts
    71
    just wanted to add that I found a way to do it: click on left upper corner of console window, click on properties, and then quick-edit mode; which allowed me to 'manually' select the text displayed on the console window and copy it. But I would still like to learn to do it programmatically...

  3. #3
    Registered User
    Join Date
    Jun 2003
    Posts
    129
    Nice quick easy way is build your own buffer.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Console Copy Program in C++
    By kaveh8 in forum C++ Programming
    Replies: 2
    Last Post: 05-08-2011, 02:13 AM
  2. SDL Window opening with Console Window
    By carrotcake1029 in forum Windows Programming
    Replies: 2
    Last Post: 12-23-2008, 03:32 PM
  3. Copy and Paste function in console apps.
    By Hakins90 in forum C Programming
    Replies: 5
    Last Post: 12-27-2007, 05:07 AM
  4. Copy To Cliipboard (console app)
    By GaPe in forum Windows Programming
    Replies: 2
    Last Post: 12-10-2003, 05:53 PM
  5. Picking up characters in console window
    By GaPe in forum C Programming
    Replies: 1
    Last Post: 11-03-2002, 06:21 PM