Skip to content

Commit 8806d5c

Browse files
committed
Initial v1.0 verision
0 parents  commit 8806d5c

File tree

2 files changed

+109
-0
lines changed

2 files changed

+109
-0
lines changed

README

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
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.

cmdmax.c

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
/*++
2+
3+
Copyright (c) 2013 by Antoni Sawicki
4+
5+
Module Name:
6+
7+
cmdmax.c
8+
9+
Abstract:
10+
11+
Maximize cmd.exe Window to match the screen size
12+
13+
Author:
14+
15+
Antoni Sawicki <as@tenoware.com>
16+
17+
License:
18+
19+
Public Domain
20+
21+
--*/
22+
23+
24+
#include <windows.h>
25+
#include <stdio.h>
26+
27+
#pragma comment(lib, "user32.lib")
28+
29+
HWND (__stdcall *CmdGetConsoleWindow)(void);
30+
31+
32+
HWND
33+
MyGetConsoleWindow(
34+
void
35+
)
36+
/*++
37+
38+
Routine Description:
39+
40+
This is a makeshift version of GetConsoleWindow() function substituted
41+
for Windows < 2000 which do not have the OS supplied version.
42+
43+
--*/
44+
{
45+
char winname[128];
46+
HWND cmdwin=NULL;
47+
int n=0;
48+
49+
_snprintf(winname, sizeof(winname), "CMDMAX:%d", GetCurrentProcessId());
50+
51+
SetConsoleTitle(winname);
52+
53+
do {
54+
n++;
55+
Sleep(100);
56+
cmdwin=FindWindow(NULL, winname);
57+
} while (!cmdwin && n<600);
58+
59+
return cmdwin;
60+
}
61+
62+
63+
64+
int
65+
main(
66+
int argc,
67+
char **argv
68+
)
69+
/*++
70+
71+
Routine Description:
72+
73+
This routine is the main program for CmdMax.
74+
75+
There are no arguments although further improvement could be made
76+
to supply user defined window size and position. If you require such
77+
functionality please email the author.
78+
79+
--*/
80+
{
81+
HANDLE hConsole;
82+
COORD buff, winmax;
83+
SMALL_RECT winpos;
84+
85+
86+
CmdGetConsoleWindow = (void *) GetProcAddress(GetModuleHandle("kernel32.dll"), "GetConsoleWindow" );
87+
88+
if(!CmdGetConsoleWindow)
89+
CmdGetConsoleWindow = (void *) MyGetConsoleWindow;
90+
91+
92+
hConsole=GetStdHandle(STD_OUTPUT_HANDLE);
93+
winmax=GetLargestConsoleWindowSize(hConsole);
94+
95+
winpos.Left=0;
96+
winpos.Top=0;
97+
winpos.Right=winmax.X-5;
98+
winpos.Bottom=winmax.Y-5;
99+
buff.X=winpos.Right+1;
100+
buff.Y=3000;
101+
102+
SetConsoleScreenBufferSize(hConsole, buff);
103+
SetConsoleWindowInfo(hConsole, TRUE, &winpos);
104+
SetWindowPos(CmdGetConsoleWindow(), HWND_TOP, 0, 0, 0, 0, SWP_NOSIZE);
105+
106+
return 0;
107+
}
108+

0 commit comments

Comments
 (0)