in reply to Re: How can I increase the cmd.exe screen size permanently - by Perly
in thread How can I increase the cmd.exe screen size permanently - by Perly

Mode command was very useful for me – the problem is that it making my scroll-up bar to disappear!

I need to print long usage for the user and the maximum size of the cmd.exe is not enough – I need buffer size , How can I set the Buffer size separately?

I run the command:

system q[mode con cols=100 lines=60];

but the buffer size diapered.

Even if I try to use Win32::Console I didn't success to resize the current cmd.exe include buffer size that enable me to print all my long usage.

Can someone give me an example how to use Win32::Console to increase and leave the current cmd.exe display size to 100 * 60, or how to use mode and define a buffer size.

Thanks

Replies are listed 'Best First'.
Re^3: How can I increase the cmd.exe screen size permanently - by Perly
by BrowserUk (Patriarch) on Apr 02, 2012 at 07:57 UTC

    Have you heard of the more command? Try typing help more

    Messing with the user's screen in order to display your long usage message is a bad idea.


    With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.

    The start of some sanity?

      Sorry to nag - but I run the following code:

      use strict; use warnings; use Win32::Console; my $OUT = Win32::Console->new(STD_OUTPUT_HANDLE); my $IN = Win32::Console->new(STD_INPUT_HANDLE); $IN->Mode(ENABLE_MOUSE_INPUT|ENABLE_WINDOW_INPUT); $OUT->Size(180, 200); my ($maxx, $maxy) = $OUT->MaxWindow; $OUT->Cls; $OUT->Cursor(-1, -1, -1, 0); $OUT->FillAttr($BG_YELLOW|$FG_BLUE, $maxy * $maxx, 0, 0); $OUT->FillChar('X', $maxy*$maxx, 0, 0); $OUT->Window(1, 0, 0, $maxx, $maxy); while ($maxx>1 and $maxy>1) { $maxx -= 5; $maxy -= 5; $OUT->Window(1, 0, 0, $maxx, $maxy); sleep 1; } $OUT->Window(1, 0, 80, 50); $OUT->Cls;

      Indeed, the screen size is dynamically variable - but if I remove/mark the sleep command than I can't see the screen resize.

      I Would love to know what I was doing wrong, how can I make my current screen resize to 80*100 and stay on this size?

      Mode command I used is good indeed, the only problem is that it disappear the buffer size and the user can't scroll the screen up and down

      Thanks.

        Indeed, the screen size is dynamically variable - but if I remove/mark the sleep command than I can't see the screen resize.

        And that is a problem because?

        Perhaps you what to see it resize in steps, but with the sleep in there it takes too long, and without the sleep it happens so fast you don't see the intermediate positions?

        If so, replace the sleep 1; with Win32::Sleep 100;; Adjust the number to suit.

        I Would love to know what I was doing wrong, how can I make my current screen resize to 80*100 and stay on this size?

        If you want to unconditionally change the screen size to 80x100, the try:

        perl -MWin32::Console -e"Win32::Console->new(STD_OUTPUT_HANDLE)->Windo +w(1, 0, 0, 50,50);"

        But realise that the call will fail if you try to size the window so that some part of it will be outside of the screen:

        C:\test>perl -Mstrict -MWin32::Console -we"Win32::Console->new(STD_OUT +PUT_HANDLE)->Window(1, 0, 0, 50,500) or die $^E;" The parameter is incorrect at -e line 1.

        In the above, the 'right' dimension specified (500) is bigger than my screen can handle with the currently selected font/size, so the call fails with "The parameter is incorrect".

        See SetConsoleWindowInfo() for more info on this.

        The thing to note here is that:

        • ->Size( x, y ) specified the size of the Screen buffer, which can be huge 1000x1000 at least.
        • ->Window( flag, top, left, bottom, right ); decides how big the window is.

        This might get you started:

        #! perl -slw use strict; use List::Util qw[ max min ]; use Win32::Console; my $OUT = Win32::Console->new(STD_OUTPUT_HANDLE); my $origAttr = $OUT->Attr; $OUT->Cls; $OUT->Size(1000, 1000); my ($maxx, $maxy) = $OUT->MaxWindow; $OUT->Window( 1, 0, 0, $maxx-1, $maxy - 1 ); my $striped = chr( $FG_BLUE | $BG_WHITE ) . chr( $FG_LIGHTBLUE | $BG_L +IGHTGRAY ); for my $row ( 1 .. 1000 ) { $OUT->WriteAttr( $striped x 500, 0, $row ); $OUT->WriteChar( '1234567890' x 100, 0, $row ); } for ( 1 .. 3 ) { for my $n ( 0 .. $maxx - 2 ) { $OUT->Window( 1, min( $maxx-2, $n ), min( $maxy-2, $n ), $maxx +-1, $maxy-1 ) or die $^E; Win32::Sleep 3 - $_; } for my $n ( 0 .. $maxx ) { $OUT->Window( 1, 0, 0, min( $maxx-1, $n ), min( $maxy-1, $n ) +) or die $^E; Win32::Sleep 3 - $_; } } $OUT->Attr( $origAttr ); $OUT->Cls;
        Mode command I used is good indeed, the only problem is that it disappear the buffer size and the user can't scroll the screen up and down

        The mode command sets the size of the buffer.

        It then also sets the size of the screen to (whichever is smaller of) that buffer size, or the maximum the screen can hold.


        With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
        Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
        "Science is about questioning the status quo. Questioning authority".
        In the absence of evidence, opinion is indistinguishable from prejudice.

        The start of some sanity?