Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles
(untagged)

Visual Studio 2010 TFS Solution CheckIn Hotkey

0.00/5 (No votes)
26 Aug 2011 1  
Quick way of showing the Solution check-in modal window on Visual Studio

Intoduction


This is a nice implementation of a keyboard shortcut to checkin your Solution that makes use of the Macro engine of Visual Studio.
This implementation will prompt the exact same modal window that shows when we choose "Check In..." from the solution context menu.

This is particulary useful not only on big solution where you have to scroll a lot to see the solution node but also when the solution context menu gets so big that finding the "Check In..." option is not that easy.

Creating the Macro


There isn't any out-of-the-box way of doing this, so we have to write a macro.
In Visual Studio, go to: Tools > Macros > Macro Explorer.

On the right side, a new pane appeared showing the Macros you have.
By default, you have two child nodes under Macros: MyMacros and Sample.
Let's use MyMacros.

  1. Right-click it and choose "New Module".
  2. Name it TFS and ckick Add.
  3. Open the created module and replace the entire file content with the code below
  4. I don't take the credit for the code below, it was taken from here.
    Imports System
    Imports EnvDTE
    Imports EnvDTE80
    Imports EnvDTE90
    Imports EnvDTE90a
    Imports EnvDTE100
    Imports System.Diagnostics
    
    Public Module TFS
    
        Sub CheckInSolution()
            DTE.Windows.Item(Constants.vsWindowKindSolutionExplorer).Activate()
    
            Dim fi As System.IO.FileInfo = New System.IO.FileInfo(DTE.Solution.FullName)
            Dim name As String = fi.Name.Substring(0, fi.Name.Length - fi.Extension.Length)
    
            DTE.ActiveWindow.Object.GetItem(name).Select(vsUISelectionType.vsUISelectionTypeSelect)
            DTE.ExecuteCommand("ClassViewContextMenus.ClassViewProject.TfsContextCheckIn")
        End Sub
    
    End Module

  5. Save the Macro and close it.



Creating the Keyboard Shortcut



  1. Go to Tools > Options > Environment > Keyboard
  2. On the listbox, search for Macros.MyMacros.TFS.ChackInSolution and select it
  3. On the Shortcut keys textbox I used: Ctrl+Shift+K, Ctrl+Shift+I

    • This combination is accomplished by pressing K and then I while holding (without releasing) the Control and Shift keys
    • The above combination was available on my environment, don't use a combination that is already in use on your environment.
    • EDIT: I previously had a Ctrl+C, Ctrl-I combination but using Ctrl+C will mess the default clipboard Copy shortcut. If you find that your shortcut messed up anything, you must reset the key assignments clicking the Reset button.

  4. Click OK, and you're done.


Now, when you use Ctrl+C, Ctrl+I anywhere in Visual Studio, the checkin modal form will appear just like it would if you choose "Check In..." from the Solution context menu.

Have fun!

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here