Visual Studio:如何在遇到断点时触发警报?

发布于 2024-07-05 13:48:27 字数 66 浏览 6 评论 0原文

当我的断点被击中时,有没有办法触发蜂鸣声/警报/声音? 我正在使用 Visual Studio 2005/2008。

Is there a way to trigger a beep/alarm/sound when my breakpoint is hit? I'm using Visual Studio 2005/2008.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

绝不放开 2024-07-12 13:48:27

您可以创建一个宏来响应断点触发而运行。 在宏中,您可以采取任何措施来发出蜂鸣声。

You can create a macro that runs in response to a breakpoint firing. In your macro, you could do whatever it takes to make a beeping noise.

朱染 2024-07-12 13:48:27

Windows XP

控制面板 -> 声音和音频... -> 程序事件 - Microsoft Developer -> 断点命中

Windows 7

控制面板 -> 所有控制面板项目 -> 声音 -> 声音(选项卡)- Microsoft Visual Studio -> 断点命中

Windows XP

Control Panel -> Sounds and Audio... -> Program Events - Microsoft Developer -> Breakpoint Hit

Windows 7

Control Panel -> All Control Panel Items -> Sounds -> Sounds (tab) - Microsoft Visual Studio -> Breakpoint Hit

蓝眼泪 2024-07-12 13:48:27

是的,您可以使用分配给断点的宏来完成此操作。 这在 VS 2005 中有效,我认为 2008 也能工作。 我假设您不希望每个断点都发出声音,否则其他答案就可以正常工作。 可能有一种方法可以播放特定的声音,但我没有深入挖掘。 以下是基本步骤:

添加新的宏模块(代码下方的步骤)

Imports System.Runtime.InteropServices
Public Module Beeps
    Public Sub WindowsBeep()
        Interaction.Beep()
    End Sub
    Public Sub ForceBeep()
        Beep(900, 300)
    End Sub
    <DllImport("Kernel32.dll")> _
    Private Function Beep(ByVal frequency As UInt32, ByVal duration As UInt32) As Boolean
    End Function
End Module
  1. 工具 => 宏=> 宏 IDE
  2. 我的宏(在项目资源管理器中)=> 添加新模块=> 名称:“Beeps”
  3. 将上面的代码复制进去。它有2个方法
    1. 第一个使用 Windows“Beep”声音
    2. 第二个强制发出“嘟嘟”声,而不是 .wav 文件。 这适用于禁用所有声音(例如控制面板 -> 声音 -> 声音方案:无声音),但听起来很难看。
  4. 查看 VS.Net 中的宏资源管理器(不是宏 IDE)以确保它在那里:)

分配到断点

  1. 在一行中添加一个断点
  2. 右键单击​​小红点
  3. 选择“当点击”
  4. 选中该框以启用宏
  5. 请从下拉列表中选择您的宏
  6. 如果您想停止, 取消选中“继续执行”。 默认情况下会选中它。

另外,还有一些方法可以播放任意 wav 文件,但这对于警报来说似乎太过分了。 也许强制的“嘟嘟”声是最好的,因为这至少听起来与 Ding 不同。

Yes, you can do it with a Macro assigned to a breakpoint. This works in VS 2005, I assume 2008 will work as well. I assume you don't want a sound on EVERY breakpoint, or the other answer will work fine. There is probably a way to play a specific sound, but I didn't dig that hard. Here are the basic steps:

Add A New Macro Module (steps below the code)

Imports System.Runtime.InteropServices
Public Module Beeps
    Public Sub WindowsBeep()
        Interaction.Beep()
    End Sub
    Public Sub ForceBeep()
        Beep(900, 300)
    End Sub
    <DllImport("Kernel32.dll")> _
    Private Function Beep(ByVal frequency As UInt32, ByVal duration As UInt32) As Boolean
    End Function
End Module
  1. Tools => Macros => Macros IDE
  2. My Macros (In Project Explorer) => Add New Module => Name: "Beeps"
  3. Copy the above code in. It has 2 methods
    1. First one uses the windows "Beep" sound
    2. Second one forces a "Beep" tone, not a .wav file. This works with all sounds disabled (eg Control Panel -> Sounds -> Sound Scheme: No Sounds), but sounds ugly.
  4. View the Macro Explorer in VS.Net (not the macro IDE) to make sure it is there :)

Assign To A Breakpoint

  1. Add a break point to a line
  2. Right click on the little red dot
  3. Select "When Hit"
  4. Check the box to enable macros
  5. Select your macro from the pulldown
  6. Uncheck "continue execution" if you want to stop. It is checked by default.

Also, there are ways to play an arbitrary wav file, but that seems excessive for an alert. Perhaps the forced "beep" is the best, since that at least sounds different than Ding.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文