Click here to Skip to main content
Click here to Skip to main content

Making F1 do something useful in Visual Studio

By , 12 Feb 2011
 
For Visual Studio 2008 and Visual Studio 2010:
 
1) Open VS, and on the Menu bar select "Tools...Macros...New Macro Project"
2) Call the project "GoogleSearchMSDN"
3) I'm so sorry about this, but VB is involved here. Not my fault, honest!
4) Rename the default Module1 to "DoGoogleSearchMSDN" - right click on the module name in the left hand pan, select "Rename"
5) Enter the following code as the module body:
    Sub GoogleSearchMSDN()
        Dim url As String
        Dim searchFor As TextSelection = DTE.ActiveDocument.Selection()
        If searchFor.Text <> "" Then
            url = "www.google.com/search?q=MSDN+" + searchFor.Text
        Else
            url = "www.google.com/search?q=MSDN"
        End If
        DTE.ExecuteCommand("View.URL", url)
    End Sub
6) Build and save your module.
7) Use the menu bar again: "Tools...Options...Environment...Keyboard"
8) In the "Show commands containing:" textbox, type "Google" - you should see your new macro.
9) Go to the "Press shortcut keys" box, and press F1
10) Press OK.
 
F1 now searches for "MSDN" plus whatever you highlighted.
 
[edit]Took out the "C#" reference in the "searches for" comment at the end - mine does, because I put that in the URL... :-O -- OriginalGriff [/edit]

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

OriginalGriff
CEO
Wales Wales
Member
Born at an early age, he grew older. At the same time, his hair grew longer, and was tied up behind his head.
Has problems spelling the word "the".
Invented the portable cat-flap.
Currently, has not died yet. Or has he?

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board.
Search this forum  
    Spacing  Noise  Layout  Per page   
GeneralReason for my vote of 5 Simple, yet brilliant idea!memberStephen Haselschwerdt16 Feb '11 - 10:14 
Reason for my vote of 5
Simple, yet brilliant idea!
GeneralReason for my vote of 5 One of those macros that you wish yo...memberctrueman14 Feb '11 - 11:30 
Reason for my vote of 5
One of those macros that you wish you'd written yourself ages ago. Thanks!
GeneralThis is great, I've been trying to get the help search to op...memberKeith.Badeau14 Feb '11 - 5:48 
This is great, I've been trying to get the help search to open in the VS browser rather than the external browser or help viewer. Unfortunately, I haven't explored macros (to my disadvantage, I suppose) and this article is the first I've read on the subject. I thought VBS was the language used for macros; are there other options as well, like C#?
GeneralRe: Regrettably, no. If there was, I'd have used it! I guess you...mvpOriginalGriff14 Feb '11 - 8:38 
Regrettably, no. If there was, I'd have used it!
I guess you could write a DLL, and reference it, but it sound like too much hassle for the amount of work I am planning on doing - I only write VS macros when it's something I can't find another way of doing...
GeneralReason for my vote of 5 Sweet, real sweet! Thank you Origin...memberVic Rauch12 Feb '11 - 17:59 
Reason for my vote of 5
Sweet, real sweet! Thank you OriginalGriff. And thank you for the VB!
GeneralReason for my vote of 5 Cool! I shall implement this right a...memberTarun.K.S12 Feb '11 - 6:16 
Reason for my vote of 5
Cool! I shall implement this right away!
GeneralReason for my vote of 5 Thanks for writing this up so clearl...memberGlenn E. Lanier II11 Feb '11 - 3:23 
Reason for my vote of 5
Thanks for writing this up so clearly. Accidentally pressing F1 has been a pain waiting for the Help to stop indexing so I can use my machine again.
GeneralReason for my vote of 5 Arise, Sir Griffmemberjim lahey10 Feb '11 - 4:26 
Reason for my vote of 5
Arise, Sir Griff
GeneralThanksmemberDmitry Sharygin16 Feb '11 - 5:18 
Very useful, thanks.
Generalcrippled version blues..memberErrolErrol14 Feb '11 - 7:35 
Played in the key of C++.
 
I've got those 'ol crippled version blues again, Baby.
My Express Version won't give me no Love.
Yes, I've got those 'ol crippled version blues again, Baby.
My Version won't give me no Macros, as you have so wonderfully described Above!
 
(This has me so upset that I may have to get "real" and buy the Pro. version!)
Thank you for this great how-to.
I currently just use a GoogleMSDN bookmark on my desktop, but your article has made me unhappy with my lot in life! Lol!! Big Grin | :-D

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Permalink | Advertise | Privacy | Mobile
Web04 | 2.6.130523.1 | Last Updated 13 Feb 2011
Article Copyright 2011 by OriginalGriff
Everything else Copyright © CodeProject, 1999-2013
Terms of Use
Layout: fixed | fluid