原創:一個相當有用的宏(for vs.net),該宏能大大的提高開發速度

來源:互聯網
上載者:User

下面的宏用於將剪貼簿裡面的url指定的檔案在vs.net中開啟以便編輯,目的是提高開啟檔案的速度
比如:你在ie中運行一個系統時,某一個頁面有錯,這個時候你需要修改這個頁面,那麼你只需要複製該頁面的url,然後到vs.net中使用一個運行宏的快速鍵就可以開啟修改該頁面了(最好事先開啟瞭解決方案,這樣該檔案是作為解決方案中的一個檔案開啟的,而不是一個單獨的與項目無關的檔案)。如果不使用宏你將不得不開啟方案總管,一層一層的展開樹,然後找到要修改的檔案

Imports EnvDTE
Imports System.Diagnostics
Imports System.Windows.Forms
Imports System.Threading

Public Module RecordingModuleModule RecordingModule
    Dim ClipString As String
    Sub TemporaryMacro()Sub TemporaryMacro()
        '// take whatever is on the clipboard and save it to an xml file
        '// intended for cut & paste from QueryAnalyzer
        Dim ClipBoardThread As System.Threading.Thread = New System.Threading.Thread(AddressOf getClipString_core)
        With ClipBoardThread
            .ApartmentState = ApartmentState.STA
            .IsBackground = True
            .Start()
            '-- Wait for copy to happen
            .Join()
        End With
        ClipBoardThread = Nothing
        If ClipString <> "" Then
            '虛擬目錄名()
            Dim VirtualName = "kxframework"
            VirtualName = LCase(VirtualName) ' added 2008-4-2
            Dim pos = InStr(LCase(ClipString), "/" & VirtualName & "/")
            If (pos = 0) Then
                pos = InStr(LCase(ClipString), "\" & VirtualName & "\")
            End If
            If (pos <> 0) Then
                ClipString = Right(ClipString, Len(ClipString) - pos - Len("\" & VirtualName & "\") + 1)
            End If
            pos = InStr(ClipString, "?")
            If (pos <> 0) Then
                ClipString = Left(ClipString, pos - 1)
            End If
            '組合成正確的實體路徑
            ClipString = "E:\科信施工項目成本管理系統\" & VirtualName & "\" & ClipString
            ClipString = Replace(ClipString, "/", "\")
            If System.IO.File.Exists(ClipString) Then
                DTE.ItemOperations.OpenFile(ClipString)
            Else
                MessageBox.Show("檔案(" & ClipString & ")未找到!")
            End If
        End If
    End Sub
    Sub getClipString_core()Sub getClipString_core()
        ClipString = Clipboard.GetDataObject().GetData(System.Windows.Forms.DataFormats.StringFormat)
    End Sub
End Module

 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.