Here's a macro which does which should get you going. The error handling is abysmal but I couldn't muster more, I absolutely hate VB :)
Also note that it only captures a class type name or interface type name, you can run it where ever you want while your cursor is inside a class or interface definition. It will capture the name of the class/interface scope.
It runs the Clipboard call in a thread, because it's a Windows Forms component and they need to run in a STAThread.
It copies the full typename to the clipboard.
Imports System
Imports EnvDTE
Imports EnvDTE80
Imports EnvDTE90
Imports EnvDTE90a
Imports EnvDTE100
Imports System.Diagnostics
Public Module SkurmedelMacros
Public Sub SetClipboard(ByVal x As Object)
System.Windows.Forms.Clipboard.SetText(CStr(x), System.Windows.Forms.TextDataFormat.Text)
End Sub
Public Sub GetTypeName()
Dim solution As Solution = DTE.Solution
Dim activePoint As TextPoint = CType(DTE.ActiveDocument.Selection, TextSelection).ActivePoint
Dim codeElem As CodeElement = _
DTE.ActiveDocument.ProjectItem.FileCodeModel.CodeElementFromPoint(activePoint, vsCMElement.vsCMElementClass)
If codeElem Is Nothing Then
codeElem = DTE.ActiveDocument.ProjectItem.FileCodeModel.CodeElementFromPoint(activePoint, vsCMElement.vsCMElementInterface)
End If
Dim ClipBoardThread As System.Threading.Thread = New System.Threading.Thread(AddressOf SetClipboard)
With ClipBoardThread
.ApartmentState = System.Threading.ApartmentState.STA
.IsBackground = True
.Start(codeElem.FullName)
.Join()
End With
ClipBoardThread = Nothing
End Sub
End Module