Take Command vs. cmd.exe

  • Thread starter mathewsdw@sbcglobal.net
  • Start date
  • This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.
M

mathewsdw@sbcglobal.net

Guest
#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?
 
Aug 9, 2009
133
0
#2
%_rows .%_columns

----- Original Message -----
Sent: Monday, February 15, 2010 5:09 PM
Subject: [Support-t-1733] Take Command vs. cmd.exe
 
#3
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 <


> 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?
>
>
>
>
>


--
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.
 

rconn

Administrator
Staff member
May 14, 2008
10,100
85
#4
> 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?
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
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 <


> 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?
>
>
>
>
>


--
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
On Mon, Feb 15, 2010 at 5:47 AM, rconn <> wrote:


> ---Quote---
> > 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
>
> ---End Quote---
> I'd be very interested in seeing this program -- can you email me a copy?
>
> Rex Conn
> JP Software
>
>
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.
 
M

mathewsdw@sbcglobal.net

Guest
#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>
 

rconn

Administrator
Staff member
May 14, 2008
10,100
85
#8
> 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.)
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