HOW TO:列出目前的鍵盤快速鍵

您可以使用這個程序來建立巨集以便產生一份清單,內容列出整合式開發環境 (IDE) 中的所有命令,以及根據目前的鍵盤對應配置對應至這些命令的所有快速鍵。

IDE 中有多項鍵盤對應配置可以使用。 您可以在 [選項] 對話方塊的 [環境] 資料夾底下,於 [鍵盤] 頁面上變更鍵盤對應配置。 如需詳細資訊,請參閱 HOW TO:使用鍵盤快速鍵

注意事項注意事項

根據您目前使用的設定或版本,您所看到的對話方塊與功能表指令可能會與 [說明] 中描述的不同。 如果要變更設定,請按一下 [工具] 功能表上的 [匯入和匯出設定]。 如需詳細資訊,請參閱 使用設定

若要列出目前的鍵盤快速鍵對應

  1. 在 [工具] 功能表中,指到 [巨集],接著按一下 [巨集 IDE]。

  2. 在 [專案總管] 中,按兩下 [MyMacros]。

  3. 在 [Module1] 上按一下滑鼠右鍵,然後按一下 [重新命名]。

  4. 輸入 KeyboardShortcuts 做為模組的新名稱。

  5. 按兩下 [KeyboardShortcuts],即可在編輯器中開啟此檔案。

  6. 在檔案中的 Public Module KeyboardShortcuts 後面貼上下列程式碼:

    Sub GetAllCommands()
    
        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
    
  7. 在 [檔案] 功能表上按一下 [儲存 MyMacros]。

  8. 切換回 Visual Studio。

  9. 從 [工具] 功能表中,指到 [巨集],接著按一下 [巨集總管]。

  10. 展開 [MyMacros],然後展開 [KeyboardShortcuts]。

  11. 在 [GetAllCommands] 上按一下滑鼠右鍵,然後按一下 [執行]。

    此巨集就會產生一份清單,內容列出 IDE 中所有可能的命令和這些命令在目前鍵盤對應配置中的所有鍵盤快速鍵對應。

  12. 在 [檢視] 功能表上,按一下 [輸出]。

    命令及其快速鍵組合就會顯示在 [輸出] 視窗中。 您可以複製這項資訊並貼入其他應用程式 (例如 Microsoft Office Excel),以便進行其他格式設定和列印選項。

請參閱

工作

HOW TO:使用鍵盤快速鍵

概念

預先定義的鍵盤快速鍵

其他資源

Visual Studio 設定