首页 \ 问答 \ 当我用空格输入输入时,批处理cmd退出(batch cmd exits as I enter the input with space)

当我用空格输入输入时,批处理cmd退出(batch cmd exits as I enter the input with space)

我正在为用户界面编写一个批处理脚本,您可以在其中输入数字1 - 10。它与此示例非常相似:

@echo OFF
:ask
cls
echo press 1 for test1
echo press 2 for test2
set /p input=
if %input% == 1 goto test1
if %input% == 2 goto test2
if %input% GTR 10 goto ask
goto ask
:test1
shutdown
:test2
net view
pause
goto ask

我有%%输入%GTR 10 goto问,最后goto问全球,因为如果有人输入不同的东西,它会回到问题。 但是,当我键入包含空格的任何内容时,它将退出提示。 我该如何解决?
提前致谢,
山姆


I am writing a batch script for an user interface where you can enter the digits 1 - 10. its pretty much like this example:

@echo OFF
:ask
cls
echo press 1 for test1
echo press 2 for test2
set /p input=
if %input% == 1 goto test1
if %input% == 2 goto test2
if %input% GTR 10 goto ask
goto ask
:test1
shutdown
:test2
net view
pause
goto ask

i have if %input% GTR 10 goto ask, and in the end goto ask in global because if someone types something different it will go back to the question. Why does it crash me out of the terminal when I type something different?


原文:https://stackoverflow.com/questions/48282362
更新时间:2022-03-19 21:03

最满意答案

使用TextRendererMeasureString的常用方法将为您提供SizeF ,其中包含您测量的字符串的边界。 大多数格式都有一点松弛,因此您可以通过将字符串添加到一起来撰写文本。

这些方法的目的是帮助您创建一个文本块,让您测量一条线是否已满或者为下一条线前进多少像素。

它们并不是真正意义上的单个字符。

为此, 这里描述一个特殊的字符串格式GenericTypographic ,它留下了空白区域。

为了获得更精确的测量,可以使用GraphicsPath.AddString然后使用GetBounds ,可能在关闭了antialias之后。

现在,如果你想精确地绘制一个角色,那么以按钮为中心就可以完成这项工作。

但是你知道所有这些并且你的目标是不同的 - 如果我理解你正确,你想要从每个角色创建位图,以便以后加入它们来形成文本。 这意味着您需要它们垂直排列,即坐在相同的基线上。

角色的大小对你没有帮助; 现在,通常你需要你没有得到的每个charcater的基线,至少不需要像'f'或甚至''等下降的任何东西。

但它也无济于事,因为在GDI中你无论如何都不打印/绘制基线。

你应该做什么,imo要么画一个长字符串和所有字符,所以它们都排成一行,然后逐个剪切字符。 或者您可以自己绘制每个字符,但是后缀全部或某些您知道具有上升和下降的字符,然后只从结果中选择第一列。


So the only way I figured out how to do this is is to first draw the string to a graphicpath, then measure all the empty spots in the graphic path, and get it's height only after I've measure every spot, then redraw the string (I have an attempt counter to limit attempts but increase em to pixel accuracy) taking the old size and new size into account by a modifier and then extract the final size and store it.

Only I got to get around the BS of every font having a weird top padding that isn't associated with it's ascent and internal overflow (ex: Ñ), as well as descent, in refrence to a 0,0 point, this way.

相关问答

更多
  • 使用TextRenderer或MeasureString的常用方法将为您提供SizeF ,其中包含您测量的字符串的边界。 大多数格式都有一点松弛,因此您可以通过将字符串添加到一起来撰写文本。 这些方法的目的是帮助您创建一个文本块,让您测量一条线是否已满或者为下一条线前进多少像素。 它们并不是真正意义上的单个字符。 为此, 这里描述了一个特殊的字符串格式GenericTypographic ,它留下了空白区域。 为了获得更精确的测量,可以使用GraphicsPath.AddString然后使用GetBound ...
  • 试试Pixel Perfect扩展程序: https : //addons.mozilla.org/en-US/firefox/addon/pixel-perfect/ Pixel Perfect是一个Firefox / Firebug扩展,允许Web开发人员和设计人员轻松地将Web组合覆盖在开发的HTML之上。 Try the Pixel Perfect extension: https://addons.mozilla.org/en-US/firefox/addon/pixel-perfect/ Pix ...
  • 在xaml中 ,将SnapsToDevicePixels设置为true。 在设置WritableBitmap的类中 ,查询ActualWidth和ActualHeight。 然后将这些与Dpi的比例因子相乘(dpi为1.25,等等)。 var width = ActualWidth * _dpi_x_scale; var height = ActualHeight * _dpi_y_scale; 我使用这些宽度和高度值来设置Gpu上渲染纹理的大小。 创建WritableBitmap时,还要使用那些缩放的宽 ...
  • 您需要了解的第一件事是iOS的视网膜显示系统。 所有控件都以坐标布局,就像它们是3GS / iPad 2或更早版本一样。 具有视网膜显示器的设备(例如iPhone 4,5和iPad 3)都使用这些相同的坐标,但屏幕尺寸加倍。 对于您的图片,请使用PNG。 您将拥有2套,一套用于较小的显示屏,另一套用于视网膜显示屏。 Apple使用文件命名约定: yourImage.png - 3GS的小图片 yourImage@2x.png - 视网膜显示的放大图像 假设图像尺寸较小,为150像素×50像素。 要从C#正确 ...
  • 使用这个xml 并在您设置后台使用的布局中 android:layout_width="50dp" android:l ...
  • 所以我发现问题是如果我在for循环中多次绘制,如下所示: for (int c = 0; c < currentwords; c++) { ev.Graphics.DrawString(allitems[index], f9, Brushes.Black, 100, 100); ev.Graphics.DrawString(allqty[index], f9, Brushes.Black, new Point(200, 200); ev.Graphics.DrawString((al ...
  • 您应该首先考虑改进算法,而不是用C ++重写。 最低的答案是原始值的平方根,所有'?' 替换为0向上舍入,最高可能的答案是模式的平方根,'?'替换为1向下舍入。 找到这两个值,迭代它们,平方并检查模式。 这样做速度更快,因为您正在迭代更少的数字并且因为您没有计算循环中的任何平方根:平方更容易。 您不需要比较字符串来检查匹配: mask = int(pattern.replace('0', '1').replace('?', '0'), 2) test = int(pattern.replace('?', ' ...
  • 使用的资源: https://stackoverflow.com/a/4847027/1815624 https://stackoverflow.com/a/21895626/1815624 得到屏幕宽度,文本大小与屏幕比例的一些参考,并计算。 结果如下: 和 注意第二个HOOOOOOOOOOOOOOOOOOOO! public class MainActivity extends Activity { Paint paint; @Override protected void o ...

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)