开发者

How Can I Create a Visual Studio Macro to Change the Keyboard Layout?

Is it possible to create a Visual Studio (2010) macro to change the keyboard layout?

I find the "copy and paste from other applications" bug in Emacs Emulation Mode a bit annoying, so what I wanted to do is create two simple macros - one to set keyboard layout to the Emacs keyboard layout, and one to switch the layout to default (I'm sure there would开发者_Python百科 be an easy way to combine them into "switch between the two", but I wanted to start simple).

Not knowing much about VS macros, I figured I could just employ the "hit record and click around" development methodology.

Unfortunately, hitting record and clicking "Tools > Options", then clicking "Keyboard", then clicking the layout combobox and selecting "Emacs" results in the following one line of code:

DTE.ExecuteCommand("Tools.CustomizeKeyboard")

Furthermore, ExecuteCommand seems to wait for the user to close the window before continuing with the execution of the macro, so I can't immediately see how to tell Visual Studio "click the combobox, select the FizzBot item", etc.

Can this be done? If so, how?

Thanks in advance.


The macros are:

Sub SetDefaultKeyboard()
    DTE.Properties("Environment", "Keyboard").Item("SchemeName").Value = "(Default)"
End Sub

Sub SetEmacsKeyboard()
    ' change "Emacs" to actual keyboard layout name
    DTE.Properties("Environment", "Keyboard").Item("SchemeName").Value = "Emacs"
End Sub

You can assign a keyboard shortcut or a toolbar button for them.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜