Skip to content

Commit

Permalink
Initial v1.0 verision
Browse files Browse the repository at this point in the history
  • Loading branch information
tenox7 committed Jan 26, 2016
0 parents commit 8806d5c
Show file tree
Hide file tree
Showing 2 changed files with 109 additions and 0 deletions.
1 change: 1 addition & 0 deletions README
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
cmdmax is a tiny Windows application that allows to maximize cmd.exe window to match the full screen size. Unlike maximize button the utility changes botch horizontal and vertical size of the console window in characters. Additionaly the buffer size is set to 3000 lines vertically. The application is intended to be used in scripts / batch jobs, Windows PE, embedded, etc.
108 changes: 108 additions & 0 deletions cmdmax.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
/*++
Copyright (c) 2013 by Antoni Sawicki
Module Name:
cmdmax.c
Abstract:
Maximize cmd.exe Window to match the screen size
Author:
Antoni Sawicki <[email protected]>
License:
Public Domain
--*/


#include <windows.h>
#include <stdio.h>

#pragma comment(lib, "user32.lib")

HWND (__stdcall *CmdGetConsoleWindow)(void);


HWND
MyGetConsoleWindow(
void
)
/*++
Routine Description:
This is a makeshift version of GetConsoleWindow() function substituted
for Windows < 2000 which do not have the OS supplied version.
--*/
{
char winname[128];
HWND cmdwin=NULL;
int n=0;

_snprintf(winname, sizeof(winname), "CMDMAX:%d", GetCurrentProcessId());

SetConsoleTitle(winname);

do {
n++;
Sleep(100);
cmdwin=FindWindow(NULL, winname);
} while (!cmdwin && n<600);

return cmdwin;
}



int
main(
int argc,
char **argv
)
/*++
Routine Description:
This routine is the main program for CmdMax.
There are no arguments although further improvement could be made
to supply user defined window size and position. If you require such
functionality please email the author.
--*/
{
HANDLE hConsole;
COORD buff, winmax;
SMALL_RECT winpos;


CmdGetConsoleWindow = (void *) GetProcAddress(GetModuleHandle("kernel32.dll"), "GetConsoleWindow" );

if(!CmdGetConsoleWindow)
CmdGetConsoleWindow = (void *) MyGetConsoleWindow;


hConsole=GetStdHandle(STD_OUTPUT_HANDLE);
winmax=GetLargestConsoleWindowSize(hConsole);

winpos.Left=0;
winpos.Top=0;
winpos.Right=winmax.X-5;
winpos.Bottom=winmax.Y-5;
buff.X=winpos.Right+1;
buff.Y=3000;

SetConsoleScreenBufferSize(hConsole, buff);
SetConsoleWindowInfo(hConsole, TRUE, &winpos);
SetWindowPos(CmdGetConsoleWindow(), HWND_TOP, 0, 0, 0, 0, SWP_NOSIZE);

return 0;
}

0 comments on commit 8806d5c

Please sign in to comment.