使用宏记录器与 VS2010 中的对话框进行交互(使用 Visual Studio 宏记录器自动输入击键)

发布于 2024-11-15 12:28:02 字数 1463 浏览 4 评论 0原文

我的其他问题中,我询问了在 VS2010 IDE 中启用特定功能的快捷方式。看起来实现这一目标的唯一方法是通过宏记录器,不幸的是我从未使用过它(因为它看起来非常强大!)。

制作宏的最简单方法是使用 CTRL+SHIFT+R 启动记录器,然后转到“调试”->“调试”。例外情况,选中我想要的所有复选框,单击“确定”,然后停止记录器。不幸的是,我所能看到的只是它打开了“例外”窗口,仅此而已。

我认为如果宏记录器不记录鼠标事件,那么它肯定会记录键盘事件,但我也错了。在编辑我的 TemporaryMacro 时,我发现它所做的唯一一件事是

DTE.ExecuteCommand("Debug.Exceptions")

我真正想做的是添加一个可以输入击键的方法,例如 DOWNALT+ TENTER

我疯狂地用谷歌搜索,浏览了MSDN,并在这里查看了SO。我很尴尬地说,我一直无法在 DTE 中找到任何有关允许我发送击键的对象的信息!希望这里有人知道该怎么做!

这是我发现的最接近关于按键自动化的文档: http: //msdn.microsoft.com/en-us/library/8h31zbch.aspx

编辑:我想出了如何发送击键,但是如何才能你将它们发送到弹出对话框???

这是我尝试过的代码:

Public Module RecordingModule
    Sub TemporaryMacro()
        DTE.ExecuteCommand("Debug.Exceptions")
        System.Windows.Forms.SendKeys.SendWait("+{TAB}")
        System.Windows.Forms.SendKeys.SendWait("{DOWN}")
        System.Windows.Forms.SendKeys.SendWait("%T")
        System.Windows.Forms.SendKeys.SendWait("{ENTER}")
    End Sub
End Module

我无法让它工作,所以我尝试调试,就在那时我意识到发生了什么 - SendWait 在对话框关闭之前不会被调用。

那么有人知道如何使用宏录制器通过键盘命令与弹出对话框进行交互吗?

In one of my other questions, I inquired about a shortcut to enable a particular feature in the VS2010 IDE. It looks like the only way to make it happen is through the Macro Recorder, which I have unfortunately never used (as it looks quite powerful!).

The straightforward way to make my macro would be to start the recorder with CTRL+SHIFT+R, then go to Debug -> Exceptions, check all of the boxes I want, click OK, and then stop the recorder. Unfortunately, all that I can see is that it opens the Exceptions window, and no more than that.

I figured that if the Macro Recorder doesn't record mouse events, then surely it must record keyboard events, but I was wrong about that, too. Upon editing my TemporaryMacro, I saw that the only thing it does is

DTE.ExecuteCommand("Debug.Exceptions")

What I really want to do is add a method that can enter keystrokes like DOWN, ALT+T, and ENTER.

I have googled like crazy, gone through MSDN, and checked here on SO. I am embarrassed to say that I have been unable to find any information about an object in DTE that allows me to send keystrokes! Hopefully, someone here will know how to do it!

This is the closest thing I've found to a document regarding keystroke automation: http://msdn.microsoft.com/en-us/library/8h31zbch.aspx

Edit: I figured it out how to send keystrokes, but how can you send them to popup dialogs???

Here's the code I tried:

Public Module RecordingModule
    Sub TemporaryMacro()
        DTE.ExecuteCommand("Debug.Exceptions")
        System.Windows.Forms.SendKeys.SendWait("+{TAB}")
        System.Windows.Forms.SendKeys.SendWait("{DOWN}")
        System.Windows.Forms.SendKeys.SendWait("%T")
        System.Windows.Forms.SendKeys.SendWait("{ENTER}")
    End Sub
End Module

I couldn't get it to work, so I tried debugging, and that's when I realized what was happening -- SendWait doesn't get called until after the dialog is dismissed.

So does anyone know how to use the Macro Recorder to interact with popup dialogs via keyboard commands?

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

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

发布评论

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

评论(1

感情旳空白 2024-11-22 12:28:02

我认为您无法将击键发送到对话框。

我建议您查看 AutoHotKey,从那里您可以定义与对话框的交互。它在 Visual Studio 之外运行,因此您可能会发现它有更多用途。

I don't think you can send keystrokes to the dialog box.

I would recommend that you take a look at AutoHotKey, from there you can define interactions with dialog boxes. It works outside of Visual Studio, so you will probably find many more uses for it.

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