I am trying to generate bookmarks in the Bookmark Window.
At first I tried to create an add-in. As I cannot find a BookmarkWindow object in the DTE2 interface, I tried to use commands such as:
dte2.ExecuteCommand("View.BookmarkWindow"); dte2.ExecuteCommand("Format.InsertBookmark"); dte2.ExecuteCommand("OtherContextMenus.BookmarkWindow.Rename");As the BookmarkWindow.Rename command does not seem to accept arguments, I tried to use the SendKeys.SendWait() method to set the bookmark name.
This works well enough when my command is called from the Tools menu, however it fails horribly when calling from a keyboard shortcut (which, sadly, is my purpose).
I then converted my add-in into a VSPackage, therefore I have access I believe to more extension functions. However I still do not find how to interact with the Bookmarks Window. Which http://msdn.microsoft.com/en-us/library/vstudio/bb165789(v=vs.110).aspx/interface should I look at?
I think you can use SVsCommandWindowsCollection Interface. You may need the method OpenExistingOrCreateNewCommandWindow.
int OpenExistingOrCreateNewCommandWindow( [InAttribute] unsigned int mode, [InAttribute] int fShow, [OutAttribute] unsigned int% puCookie )
[in] Specifies if the command window should be visible when opened or created.
[out] A cookie for the command window. Use when closing the window with Close.and in other methods of this interface.
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
Click HERE to participate the survey.
Hi Anna, thank you for the reply.
Are you suggesting me to use the IVsCommandWindow.ExecuteCommand method with the "OtherContextMenus.BookmarkWindow.Rename" command?
Then will I be able to pass the string I want to rename my bookmark to as well? I cannot test it right now.
I did not investigate the method suggested by Anna Cc yet.
If you want to give this method a try, you can get the extension here at visualstudiogallery.
I would be interested if you happened to find a better way to rename Visual Studio bookmarks.
I briefly researched and played with the SVsCommandWindowsCollection class, but didn't see how I could send arguments to that rename field. I would be greatly interested in a better solution as well, since if I don't get this working as needed, I will be forced to "reinvent the wheel" by creating a whole new Bookmarking window, like this plug-in "Numbered Bookmarks". Anyways, thanks so much for sharing your code! I'm still relatively new to Visual Studio but have found the community is great and I'm looking forward to giving back as much as I can.