在vs中获得当前所有快捷键代码

本文提供了一段Visual Basic脚本,用于枚举Visual Studio环境中所有可用的命令及其快捷键。通过输出这些信息到宏输出窗口,开发者可以更好地管理和定制其工作环境。
ms-help://MS.MSDNQTR.v90.en/dv_vssettings/html/bbfc1243-fa27-45df-9c4b-6bca181132d6.htm


 

Sub GetAllCommands()
        
Dim getCommandsWithSCOnly As Boolean
        
Dim cmd As Command
        
Dim cmdCollection As Commands
        
Dim ow As OutputWindow = DTE.Windows.Item(Constants.vsWindowKindOutput).Object
        
Dim owp As OutputWindowPane
        
Dim exists As Boolean
        
Dim i As Integer

        i 
= 1
        exists 
= False

        
For Each owp In ow.OutputWindowPanes
            
If owp.Name = "Macro Output" Then
                exists 
= True
                
Exit For

            
End If
            i 
= i + 1
        
Next

        
If exists Then
            owp 
= ow.OutputWindowPanes.Item(i)
        
Else
            owp 
= ow.OutputWindowPanes.Add("Macro Output")
        
End If

        owp.Clear()

        
' Output 1 line per command
        For Each cmd In DTE.Commands
            
Dim binding As Object
            
Dim shortcuts As String

            shortcuts 
= ""


            
For Each binding In cmd.Bindings
                
Dim b As String
                
Dim sArray() As String
                b 
= binding
                shortcuts 
= shortcuts + b + " "
            
Next

            shortcuts 
= shortcuts.Trim()

            
If Not cmd.Name.Trim().Equals(""Then

                owp.OutputString(cmd.Name 
+ vbTab + shortcuts + vbCrLf)
            
Else
                owp.OutputString(cmd.Guid.ToString() 
+ ":" + cmd.ID.ToString() + vbTab + shortcuts + vbCrLf)
            
End If

        
Next    
End Sub
 


转载于:https://www.cnblogs.com/MichaelPeng/archive/2010/12/22/1913988.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值