Windows - 控制台输出是否会无意中导致系统发出蜂鸣声?
我有一个 C# 控制台应用程序,它向控制台记录很多内容(使用 Trace
)。 它记录的一些内容是网络消息的压缩表示(因此其中很多内容被呈现为时髦的非字母字符)。
应用程序运行时,我经常听到系统蜂鸣声。 是否有可能是我写入控制台的某些“文本”导致了这些问题?
(我所说的系统蜂鸣声是指 PC 机箱内的低技术扬声器发出的声音,而不是任何类型的 Windows 声音方案 WAV)
如果是这样,有什么方法可以为我的应用程序禁用它吗? 我希望能够输出任何可能的文本,而不会将其解释为声音请求。
I have a C# console application that logs a lot to the console (using Trace
). Some of the stuff it logs is the compressed representation of a network message (so a lot of that is rendered as funky non-alphabetic characters).
I'm getting system beeps every so often while the application is running. Is it possible that some "text" I am writing to the console is causing them?
(By system beep, I mean from the low-tech speaker inside the PC case, not any kind of Windows sound scheme WAV)
If so, is there any way to disable it for my application? I want to be able to output any possible text without the it being interpreted as a sound request.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
这通常是由于输出字符代码 7、CTRL-G(即 BEL(响铃)字符)引起的。
购买新电脑或主板时,我通常要做的第一件事是确保主板到扬声器的电线没有连接。 自从 Commander Keen 时代以来,我就没有使用过扬声器(移除那根电线是与操作系统无关的停止声音的最佳方法:-)。
That's usually caused by outputting character code 7, CTRL-G, which is the BEL (bell) character.
The first thing I normally do when buying a new computer or motherboard is to ensure the wire from the motherboard to the speaker is not connected. I haven't used the speaker since the days of Commander Keen (and removing that wire is the best OS-agnostic way of stopping the sound :-).
将“蜂鸣”键设置为“否”。
set the "Beep" key to "no".
当然,如果您将 ASCII 控制代码“Bell”(0x7) 输出到控制台,它会发出蜂鸣声。
absolutely, if you output ASCII control code "Bell" (0x7) to a console, it beeps.
如果您不想发出蜂鸣声,则必须在输出之前替换 0x7 字符,或者禁用“Beep”设备驱动程序,您可以在“非即插即用驱动程序”部分中找到该驱动程序,如果您打开“显示隐藏设备”选项。 或者把喇叭拿出来。
If you don't want if to beep, you'll either have to replace the 0x7 character before outputting it, or disable the "Beep" device driver, which you'll find in the Non-Plug and Play Drivers section, visible if you turn on the Show Hidden Devices option. Or take the speaker out.
即使您检查输入的 BELL 字符,它仍然可能发出蜂鸣声。 这是由于字体设置和 unicode 转换造成的。 有问题的字符是 U+2022,子弹。
Raymond Chen 解释:
Even if you check the input for BELL characters, it may still beep. This is due to font settings and unicode conversion. The character in question is U+2022, Bullet.
Raymond Chen explains:
如果未在操作系统级别禁用,输出字符串中的 \b 将引起蜂鸣声。
\b in output string will cause beep, if not disabled on the OS level.