Visual Studio 2010 - List Current Keyboard Shortcuts(列出目前快速鍵清單)

Visual Studio 2010 - List Current Keyboard Shortcuts(列出目前快速鍵清單)

一、參考資料:
List Current Keyboard Shortcuts

二、建立巨集:
1.VS2010工具->巨集->巨集IDE:開啟MS VisualStudio Macro
2.VisualStudio Macro專案總管:
(1)修改模組名稱Module1為KeyboardShortcuts
1
(2)貼上程式碼到模組,並存檔,關閉MS VisualStudio Macro,回到VS2010上:


    Dim cmd As Command
    Dim ow As OutputWindow = DTE.Windows.Item(Constants.vsWindowKindOutput).Object
    Dim owp As OutputWindowPane
    Dim exists As Boolean
    Dim i As Integer
    Dim sArray() As String

    sArray = New String() {}
    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
            b = binding
            If Not shortcuts = "" Then
                shortcuts += "--OR-- "
            End If
            shortcuts = shortcuts + b + " "
        Next

        shortcuts = shortcuts.Trim()

        If Not cmd.Name.Trim().Equals("") And Not shortcuts.Equals("") Then
            sArray.Resize(sArray, sArray.Length + 1)
            sArray(sArray.Length - 1) = cmd.Name + vbTab + shortcuts
        End If
    Next

    Array.Sort(sArray)
    owp.OutputString(String.Join(vbCrLf, sArray))

End Sub


三、執行巨集:

(1)VS2010工具->巨集->巨集總管
(2)MyMacros->KeyboardShortcuts->GetAllCommands按右鍵執行.
2
(3)檢視主選單->輸出:產生VS2010快速鍵列表
3