Click here to Skip to main content
15,885,129 members
Articles / DevOps / TFS
Tip/Trick

Visual Studio 2010 TFS Solution CheckIn Hotkey

Rate me:
Please Sign up or sign in to vote.
5.00/5 (1 vote)
26 Aug 2011CPOL2 min read 16.4K   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, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Architect
Switzerland Switzerland
Senior IT Consultant working in Switzerland as Senior Software Engineer.

Find more at on my blog.

Comments and Discussions

 
-- There are no messages in this forum --