# Resize and move batch window?



## NoNamed (Dec 22, 2009)

I'm making a quick chat in a batch file. For fun. I'm doing this by having one window that you type in, and another window that displays messages. It would be alot easier, if I could resize the windows, and move their position on the screen. So is this possible?


----------



## Squashman (Apr 4, 2003)

If you create a shortuct to launch the batch file you can make all those settings on the shortcut.


----------



## Ent (Apr 11, 2009)

If you right click the drag bar on the prompt window, you can choose either Properties or Default to change things like the size and colour. Properties of course does it immediately, while Default is permenant.


----------



## TheOutcaste (Aug 8, 2007)

You can change the size using the Mode command
*Mode Con Cols=xx Lines=xx*
where *Cols* is width in characters, and *Lines* is height in lines

Changing the position requires creating a profile in the registry. Windows saves settings for Command Prompt windows based on the title, so if you open a window with a given title, you can control the properties for that window.

The following creates a profile in the registry, opens the first window, changes the position in that profile, then opens the 2nd window.
Commands are passed on the Start line to change the title and prompt of each window, and to change the color of the 2nd.
You can change the color in the registry, but may need to add a delay, as the registry may be updated before the first window has read the color values.

```
@Echo Off
:: This first title is used to store the registry setting
:: You can use it for the title of the First window, or change
:: The Title of both windows after opening
Set _Title=ChatPrompt
:: Set Height in lines, Width in characters. Buffer width is set
:: to the same value as the window width
Set _Height=10
Set _Width=60
Set _BHeight=500
Set _BWidth=%_Width%
:: Set position of the Top left corner in pixels
:: Position is relative to the Top left corner of the screen
Set _xPos=30
Set _yPos=20
:: Color values are the same as for the Color command
Set _Color=1E
:: Calculate hex values needed in the registry
Set /A _BufferSize=_BHeight*0x10000+_BWidth
Set /A _WindowPos=_yPos*0x10000+_xPos
Set /A _WindowSize=_Height*0x10000+_Width
:: This command will be passed to the Prompt to change the Title and Prompt
:: The ampersand must be escaped
Set _Cmd=Title Send^&Prompt $T$G
Call :_OpenCP %_BufferSize% %_Color% %_WindowPos% %_WindowSize% "%_Title%" "%_CMD%"
:: Increase the _yPos value so 2nd window is below the first.
:: 12 is the height in pixels for the font being used.
:: 40 is a value to allow for the height of the Title Bar. Adjust as needed
Set /A _yPos=_yPos+_Height*12+40
Set /A _WindowPos=_yPos*0x10000+_xPos
:: This command will be passed to the Prompt to change the Title, Prompt, and Color
Set _Cmd=Title Receive^&Prompt $G^&Color 0A
Call :_OpenCP %_BufferSize% %_Color% %_WindowPos% %_WindowSize% "%_Title%" "%_CMD%"
Goto :EOF
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: Subroutines
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:_OpenCP
Reg Add "HKCU\Console\%~5" /V ScreenBufferSize /T REG_DWORD /D %1 /F
Reg Add "HKCU\Console\%~5" /V ScreenColors /T REG_DWORD /D 0x%2 /F
Reg Add "HKCU\Console\%~5" /V WindowPosition /T REG_DWORD /D %3 /F
Reg Add "HKCU\Console\%~5" /V WindowSize /T REG_DWORD /D %4 /F
Start "%~5" %COMSPEC% /K %6
```


----------

