1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Take Command vs. cmd.exe

Discussion in 'Support' started by mathewsdw@sbcglobal.net, Feb 14, 2010.

  1. I have a command-line program that I originally wrote years ago that has a lot of capabilities and options, enough so that it has a fairly complete and detailed help system built into it. Said "help system" is invoked by entering "command-name /?", after which the screen is cleared and a series of "help screens" are displayed, one by one. In cmd.exe, the message "Hit ESC(ape) to quit, any other key to continue." is displayed at the bottom of every help screen. Said program (written in C++) uses the API/library function "GetConsoleScreenBufferInfo" to get information about the number of rows in the screen, and the API/library function "SetConsoleCursorPosition" to move the cursor to the bottom of the screen before writing the "Hit ESC(ape).." message. Problem is, said code does not work at all in "tcmd/tcc". In truth, I don't really know if the call to "GetConsoleScreenBufferInfo" works, but it doesn't really matter because the call to "SetConsoleCursorPosition" definitely does not work, even if I hard-code the screen coordinates of where I want the message to be displayed. The question is, of course, what can I do to fix this, is there a "JPSoft" equivalent of these function(s) that I should be calling? If the answer is "yes" what are they and where can I get them? If not, what are the TCMD/TCC equivalents, if any, to this functionality?
     
  2. Kachupp

    Joined:
    Aug 9, 2009
    Messages:
    133
    Likes Received:
    0
    %_rows .%_columns

    ----- Original Message -----
    Sent: Monday, February 15, 2010 5:09 PM
    Subject: [Support-t-1733] Take Command vs. cmd.exe
     
  3. Jim Cook

    Joined:
    May 20, 2008
    Messages:
    605
    Likes Received:
    0
    I know that GetConsoleScreenBufferInfo returns good data; I use it in a
    program I wrote that works in TCMD/TCC. I have not tried the set cursor
    position, however. I'll try that when I get a chance and post my results.

    On Sun, Feb 14, 2010 at 8:09 PM, mathewsdw@sbcglobal.net <




    --
    Jim Cook
    2010 Sundays: 4/4, 6/6, 8/8, 10/10, 12/12 and 5/9, 9/5, 7/11, 11/7.
    Next year they're Monday.
     
  4. rconn

    rconn Administrator
    Staff Member

    Joined:
    May 14, 2008
    Messages:
    9,730
    Likes Received:
    80
    Neither TCC nor CMD.EXE has any control over how an executable runs or
    displays its output. (And it would be an egregious breach of Windows
    security if they did!) TCC uses GetConsoleScreenBufferInfo() and
    SetConsoleCursorPosition() for all of its I/O, so I know there's no issue
    with using them.

    I'd be very interested in seeing this program -- can you email me a copy?

    Rex Conn
    JP Software
     
  5. Jim Cook

    Joined:
    May 20, 2008
    Messages:
    605
    Likes Received:
    0
    The embedded program runs just as I'd expect for me, with the console
    cleared first, or full of text, or scrolled partway between.

    #include <windows.h>

    int main(int argc, char * argv[])
    {
    HANDLE hCON = GetStdHandle(STD_OUTPUT_HANDLE);
    CONSOLE_SCREEN_BUFFER_INFO ConsoleScreenBufferInfo;
    COORD Position;

    GetConsoleScreenBufferInfo(hCON, &ConsoleScreenBufferInfo);
    Position.X = ConsoleScreenBufferInfo.srWindow.Left;
    Position.Y = ConsoleScreenBufferInfo.srWindow.Bottom;
    SetConsoleCursorPosition(hCON, Position);
    printf("This text begins at the lower left corner");
    getch();
    }


    On Sun, Feb 14, 2010 at 8:09 PM, mathewsdw@sbcglobal.net <




    --
    Jim Cook
    2010 Sundays: 4/4, 6/6, 8/8, 10/10, 12/12 and 5/9, 9/5, 7/11, 11/7.
    Next year they're Monday.
     
  6. Jim Cook

    Joined:
    May 20, 2008
    Messages:
    605
    Likes Received:
    0
    On Mon, Feb 15, 2010 at 5:47 AM, rconn <> wrote:


    I would also be happy to look into it, if you want to email to me directly.

    --
    Jim Cook
    2010 Sundays: 4/4, 6/6, 8/8, 10/10, 12/12 and 5/9, 9/5, 7/11, 11/7.
    Next year they're Monday.
     
  7. <windows.h>Guys,

    Thanks for you input, but that code, while being slightly different than my own, didn't solve the problem. First a little bit of background so you can completely understand the situation - I am visually impaired, so to speak, so I have a larger font for TCC/TCMD and (I think) a larger window. It isn't that the message isn't showing up, (and I don't think I realized this), the message is showing up well beyond the visible bottom of the window, i. e. it's visible if I use the scroll bar on the right side of the window to scroll down to the bottom of the window. Also, and this is really weird, after my command is done, when writing any text that causes the window to scroll down, that text is a jumbled mess because it is "mixed in with" text that had previously been written to the bottom of the window. (The "cls" command doesn't seem to "clear" beyond the visible part of the window.)

    Finally, Rexx and Jim, I need your e-mail addresses. I could make a probably good guess for you, Rexx, but I don't have a clue for you, Jim. You are welcome to e-mail me this information if you want to keep it somewhat confidential, mathewsdw@sbcglobal.net. (BTW, understand that, while they may be available somewhere in the message(s) or on this website, my visual impairments make searching for such things rather difficult. I'm just one step above being effectively blind when it comes to things like small fonts on computer screens. I am absolutely dependent on the Windows "Magnifier" application, but it, by its very nature, only shows a limited amount of screen "real estate".)
    </windows.h>
     
  8. rconn

    rconn Administrator
    Staff Member

    Joined:
    May 14, 2008
    Messages:
    9,730
    Likes Received:
    80
    CLS only clears the current window (unless you use the /C option). It
    sounds like you're using screen buffer coordinates when you should be using
    window coordinates.

    Rex Conn
    JP Software
     

Share This Page