Im looking to write a visual studio addin that can intercept the default online help command and grab the MSDN library URL when F1 help is called on a class or type.
For example say I place my cursor on the keyword string and press F1 it usually automatically opens the browser and navigates to the help documentation for the string reference type. I want to grab the URL passed to the browser before it reaches the browser.
Is it possible to write a visual studio addin/extension that can intercept the default F1 help command ??
If the above can be done any pointers as to where to start?
About 10 years ago, when I worked at Microsoft, I wrote the specification for the original "Online F1" feature in Visual Studio 2005. So my knowledge is somewhat authoritative but also likely out of date. ;-)
You can't change the URL that Visual Studio is using (at least I don't know how to change it), but you can simply write another add-in which steals the F1 key binding, uses the same help context that the default F1 handler does, and direct the user to your own URL or app.
First, some info about how Online F1 works:
components of the Visual Studio IDE push keywords into the "F1 Help Context" which is a property bag of information about what the user is doing: e.g. current selection in the code editor, type of file being edited, type of project being edited, etc.
when the user presses F1, the IDE packages that help context into a URL and opens a browser pointing at MSDN.
Here's a sample URL, in this case when pressing F1 in the VS2012 HTML editor when the CSS property "width" was selected
The "k" parameter above is contains the help context inside visual studio. Help context contains both "keywords" (text strings) and "attributes" (name/value pairs) which various windows inside Visual Studio use to tell the IDE about what the user is doing right now.
The CSS editor pushed two keywords: "width" that I selected, and "vs.csseditor" which MSDN can use as a "fallback" if, for example, my selection is not found on MSDN.
There's also some contextual filtering attributes:
These ensure that F1 loads the page for the correct language or technology, in this case CSS. (The other filter for, .NET 4.0, is there because the project I have loaded is targeting .NET 4.0)
Note that context is ordered. The "width" keyword is more important than the ones below it.
The actual help content on MSDN has metadata (manually set by the teams who author the documentation) containing keywords and name/value context properties associated with that page. For example, the css width property documentation on MSDN, when it's stored on MSDN servers, has a list of keywords associated with it (in this case: "width") and a list of contextual properties (in this case: "DevLang=CSS"). Pages can have multiple keywords (e.g. "System.String", "String") and multiple context properties (e.g. "DevLang=C#", "DevLang=VB", etc.).
When the list of keywords gets to the MSDN Online F1 service, the algorithm is something like this, with the caveat that it may have changed in the last few years:
Here's a code sample for how a Visual Studio add-in can:
I'm leaving out all the Visual Studio add-in boilerplate code-- if you need that too, there should be lots of examples in Google.
All very exciting but potentially over engineered? I have a programmable mouse like most do. I have set one of the buttons to search. ie Click on word and browser opens in favourite search engine for the word. Usually the MSDN help is on that list. AS Is SO links. I like effective and simple soultions :-)