1. Set/get the cmd/windows buffer size, position and look
Operations: getconsoledim, setbuffersize, getdisplaydim, getwindowbounds, setwindowpos, setwindowtransparency, setwindowstyle, getwindowstyle, setpalette, getpalette, fullscreen, showwindow, setwindowsize, windowlist, getfullscreen, getdisplayscale
Note that since CmdWiz v1.6, all window/screen coordinates use unscaled display values.
1.0 Using other windows than the console window
Since CmdWiz 1.2, a number of operations can be used for other windows than the console window. These operations are: setwindowpos, setwindowsize, getwindowbounds, setwindowtransparency, showwindow, getwindowstyle, setwindowstyle, insertbmp (setmousecursorpos, getmousecursorpos, and sendkey might also be helpful but no specific window is set)
In order to specify which window to be affected, the
last argument of the operation must follow this form:
[/h:HWND|/p:pId|/t:tId|"/n:processName"|"/w:windowTitle[:F]"]
This data can (but does not have to) be obtained by using the cmdwiz
windowlist operation.
Note that only one of the options may be used. No spaces are allowed between the switch and the data
/h: must specify the window handle. This handle is guaranteed to be unique per window.
/p: must specify the process id. This id is not necessarily unique. The Cmdwiz operation will stop once it finds the first window with this processId (but since version 1.7 then try to find a main window, see below).
/t: must specify the thread id. This does not appear to work in all cases. Another approach is recommended if possible.
"/n:" must specify the process name. The whole parameter must be within quotes if the name contains spaces. The process name is not necessarily unique per window. Since version 1.7, the search must match only the beginning of the process name (which may or may not be the full name), and it is not case sensitive.
"/w:" must specify the window title. The whole parameter must be within quotes if the title contains spaces. The title is not necessarily unique per window. Since version 1.7, the search must match only the beginning of the title, and it is not case sensitive. To force a FULL title match, it is possible to add :F to the end of the search string.
Since version 1.7, using any other switch than /h and /w will automatically try to find the "main window" of the program, i.e. the visible one. Some programs may have several main windows open, in which case the user will still have to use /h or /w to point to the exact right window.
1.1 getconsoledim
Prints column/row dimensions of current console, OR returns one of these dimensions in ERRORLEVEL.
Usage: cmdwiz getconsoledim [w|h|sw|sh|cx|cy]
Without parameters, getconsoledim will print a line of the form:
WIDTH 80 HEIGHT 50 SCREEN_WIDTH 80 SCREEN_HEIGHT 50 SCROLL_X 0 SCROLL_Y 0
WIDTH and HEIGHT are the actual number of columns and rows of the console buffer, SCREEN_WIDTH/SCREEN_HEIGHT is the amount of visible columns/rows on the screen, and SCROLL_X/SCROLL_Y is the "position" in the buffer, i.e how far we have scrolled into the buffer from the top left position.
If supplying a parameter, nothing is printed, but the requested dimension is returned in ERRRORLEVEL. Use w/h for WIDTH/HEIGHT, sw/sh for SCREEN_WIDTH/SCREEN_HEIGHT, cx/cy for SCROLL_X/SCROLL_Y values.
1.2 setbuffersize
Set the scroll buffer column/row size. It is not a replacement for "mode", since it does not change the number of visible columns/rows, only the size of the scroll buffer.
Usage: cmdwiz setbuffersize [width|keep|- height|keep|-]
The value(s) given can not be smaller than the currently visible number of columns/rows.
For both width and height, you can specify "keep" (or short "k") to mean "keep current value".
To remove a scrollbar (if present), use - for width and/or height.
1.3 getdisplaydim
Get the width or height of the Windows desktop. This may be useful to e.g position the console window with setwindowpos.
Usage: cmdwiz getdisplaydim [w|h] [scaled]
Since version 1.5, the requested result is
unscaled by default (i.e. not affected by Windows display scale settings). Supply the "scaled" argument to get the scaled result.
The requested dimension is returned in ERRORLEVEL.
1.4 getwindowbounds
Get the position of the console window (or other window) in screen coordinates or its width/height in pixels.
Usage: cmdwiz getwindowbounds [x|y|w|h] [includeBorders|excludeBorders|alwaysExcludeBorders] [/h:HWND|/p:pId|/t:tId|"/n:processName"|"/w:windowTitle"]
By default, returned bounds include the title and borders of the window (including invisible borders in Windows 10). Use
excludeBorders (or
e for short) as third parameter to disable this. Use
alwaysExcludeBorders/a to ignore window settings indicating that the window does not have a border and/or title.
The requested value is returned in ERRORLEVEL.
See 1.0 for information on how to use the last parameter to affect another window than the console window.
1.5 setwindowpos
Set the position of the console window (or other window) in screen coordinates.
Usage: cmdwiz setwindowpos [x|keep y|keep] [/h:HWND|/p:pId|/t:tId|"/n:processName"|"/w:windowTitle"]
For both x and y, you can specify "keep" (or short "k") to mean "keep current coordinate".
See 1.0 for information on how to use the last parameter to affect another window than the console window.
1.6 setwindowtransparency
Sets the transparency level of the console window (or other window). The whole window is affected.
Usage: cmdwiz setwindowtransparency [0-100] [/h:HWND|/p:pId|/t:tId|"/n:processName"|"/w:windowTitle"]
Note that a value of 100 will make the console window completely invisible!
See 1.0 for information on how to use the last parameter to affect another window than the console window.
1.7 setwindowstyle
Sets or clears a flag in the console window (or other window) properties, affecting its look or behaviour.
Usage: cmdwiz setwindowstyle set|clear standard|extended value1 [value2] ... [/h:HWND|/p:pId|/t:tId|"/n:processName"|"/w:windowTitle"]
This operation is rather tricky to use. Please have a look at these two pages:
https://msdn.microsoft.com/en-us/librar ... 32600.aspx (for 'standard' style values) and
https://msdn.microsoft.com/en-us/librar ... 00543.aspx (extended style values).
To set or clear a flag, first determine if it is a standard or extended flag you want to affect, then copy the corresponding value.
See 1.0 for information on how to use the last parameter to affect another window than the console window.
Examples:
Disable mouse resizing of window:
cmdwiz setwindowstyle clear standard 0x00040000L
Disable maximizing window:
cmdwiz setwindowstyle clear standard 0x00010000L
Disable all input to window (not recommended...) :
cmdwiz setwindowstyle set standard 0x08000000L
1.8 getwindowstyle
Checks if a flag of the console window (or other window) properties is set or not.
Usage: cmdwiz getwindowstyle standard|extended value [/h:HWND|/p:pId|/t:tId|"/n:processName"|"/w:windowTitle"]
Returns ERRORLEVEL 1 if style flag set, otherwise 0.
See 1.7 for useful links.
See 1.0 for information on how to use the last parameter to affect another window than the console window.
Example to check if title bar is enabled:
cmdwiz getwindowstyle standard 0x00C00000L, followed by
echo %ERRORLEVEL%
1.9 setpalette
Sets one or more colors in the cmd window palette (starting from index 0, max 16 colors)
Usage: cmdwiz setpalette [RRGGBB[,RRGGBB...]]
Example (set color 0-2 to pink,white,yellow ): cmdwiz setpalette ff0088,ffffff,ffff00
To restore cmd's default palette, you can use: cmdwiz setpalette 000000,000080,008000,008080,800000,800080,808000,c0c0c0,808080,0000ff,00ff00,00ffff,ff0000,ff00ff,ffff00,ffffff
1.10 getpalette
Prints the RGB values of the current 16 colors of the cmd window. The string can be used as input for setpalette.
Usage: cmdwiz getpalette
1.11 fullscreen
Turns fullscreen use on or off for the console window.
Usage: cmdwiz fullscreen [0|1] [legacy]
Note: The fullscreen operation now uses the official Windows API SetConsoleDisplayMode, whereas previously it used code from carlos fscreen program. However, SetConsoleDisplayMode is not available on older Windows versions such as Windows 7. Therefore, if the initial API call fails, the operation will use the legacy fullscreen mode instead, as well as RETURN ERRORLEVEL -1 to indicate this.
It is also possible to force legacy mode on all machines using the
legacy argument.
Note that the API and the legacy fullscreen modes look different: in the legacy mode, there are borders around the screen, and also, the bottom task bar is visible.
1.12 showwindow
Maximize, minimize, or restore the console window (or other window), or set its position in the window hierarchy, or close the window.
Usage: cmdwiz showwindow [minimize|maximize|restore|topmost|top|bottom|close|value:n] [/h:HWND|/p:pId|/t:tId|"/n:processName"|"/w:windowTitle"]
If you specify the
topmost argument, the window will hereafter become a topmost window, i.e. always be on top of other windows. To disable this, set it to
top or
bottom.
It is also possible to affect the window in some other ways, using the values at
https://msdn.microsoft.com/en-us/librar ... s.85).aspx
See 1.0 for information on how to use the last parameter to affect another window than the console window.
Example: cmdwiz showwindow value:0
will hide the console window completely. Not recommended, because as far as I know you cannot get it back (but the process is still running, as Task Manager will show)
1.13 setwindowsize
Set the size of the console window (or other window) in pixels.
Usage: cmdwiz setwindowsize [w|keep h|keep] [/h:HWND|/p:pId|/t:tId|"/n:processName"|"/w:windowTitle"]
For both w and h, you can specify "keep" (or short "k") to mean "keep current size".
See 1.0 for information on how to use the last parameter to affect another window than the console window.
1.14 windowlist
Print a list of all (titled) main windows to stdout.
Usage: cmdwiz windowlist [all]
The output format is the following:
window handle|process ID|thread ID|process name|window title
Use the 'all' argument to include untitled windows in the list as well.
1.15 getfullscreen
Return information about the fullscreen status of the cmd window.
Usage: cmdwiz getfullscreen
Returns -1 if failed to get info, 0 if console is windowed, 1 if fullscreen, 2 if 'fake' (legacy) fullscreen
1.16 getdisplayscale
Return the display scale (set in Windows Display settings).
Usage: cmdwiz getdisplayscale
Returns 100 if standard scaling is applied, otherwise the set scaling value
If scaled coordinates from a window operation (e.g. getwindowbounds) is needed, this formula can be used: scaled=unscaled*100/displayscale