CMD:独立于窗口高度设置缓冲区高度 [英] CMD: Set buffer height independently of window height

查看:277
本文介绍了CMD:独立于窗口高度设置缓冲区高度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近了解到,我可以使用 mode x,y 来控制运行我的程序的CMD窗口的大小。然而,我最近注意到,这设置了缓冲区大小,窗口将调整匹配或最大在屏幕尺寸。



我想使用模式100,50 为窗口大小,但我也想保持一个arger缓冲区 - 至少开发我想要模式



解决方案

我不认为有一个本地批处理命令,可以独立控制缓冲区和窗口大小。 .NET可以控制两者,但我不认为VBScript或JScript可以访问该功能。但是powershell可以:-)参见如何扩展Windows PowerShell控制台的宽度?



幸运的是,新的设置保存在CMD PowerShell退出时的窗口。



重要的是窗口大小总是小于或等于缓冲区大小。为了简化操作,我首先使用MODE将窗口和缓冲区设置为所需的窗口大小,然后使用powershell设置缓冲区大小。



简单的 conSize.bat 混合批处理/ powershell脚本将大小作为参数:

  @echo off 
:conSize winWidth winHeight bufWidth bufHeight
mode con:cols =%1 lines =%2
powershell -command& {$ H = get-host; $ W = $ H.ui .rawui; $ B = $ W.buffersize; $ B.width =%3; $ B.height =%4; $ W.buffersize = $ B;}
pre>

要获得所需的大小,您只需使用

 调用conSize 100 50 100 9999 


I've recently learned that I can control the size of the CMD window running my program with mode x,y. However I just as recently noticed that this sets the buffer size, and the window will adjust to match or max out at the screen size.

I would like to use mode 100,50 for the window size, but I also want to keep a arger buffer - for development at least I want mode 100,9999.

Is there any way to do this?

解决方案

I don't think there is a native batch command that gives independent control of buffer and window sizes. .NET can control both, but I don't think VBScript or JScript can access that functionality. But powershell can :-) See How Can I Expand the Width of the Windows PowerShell Console?

Thankfully, the new settings are preserved in the CMD window when PowerShell exits.

It is important that the window size is always less than or equal to the buffer size. To simplify things, I first use MODE to set both the window and buffer to the desired window size, and then I use powershell to set the buffer size.

Here is a simple conSize.bat hybrid batch/powershell script that takes the sizes as parameters:

@echo off
:conSize  winWidth  winHeight  bufWidth  bufHeight
mode con: cols=%1 lines=%2
powershell -command "&{$H=get-host;$W=$H.ui.rawui;$B=$W.buffersize;$B.width=%3;$B.height=%4;$W.buffersize=$B;}"

To get your desired size, you would simply use

call conSize 100 50 100 9999

这篇关于CMD:独立于窗口高度设置缓冲区高度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆