> I would like to be able to intercept the F5 key so I can run some
> operations before the debug session starts. Is there a way to do
> this? I have an addin that listens for the WM_KEYUP event but it's
> not catching any.
If you are using in add-in, the easiest way is to listen to the
EnvDTE.Commands.BeforeExecute event for the Debug.Start command. Here
is some C# add-in code that will do this:
private DTE dte;
private CommandEvents commandEvents;
public void OnConnection(object application, ext_ConnectMode
connectMode, object addInInst, ref Array custom)
{
dte = (DTE)application;
commandEvents =
dte.Events.get_CommandEvents("{5EFC7975-14BC-11CF-9B2B-00AA00573819}",
295); // Debug.Start command...
commandEvents.BeforeExecute += new
_dispCommandEvents_BeforeExecuteEventHandler(ehBeforeDebugStart);
}
public void OnDisconnection(ext_DisconnectMode disconnectMode, ref
Array custom)
{
commandEvents.BeforeExecute -= new
_dispCommandEvents_BeforeExecuteEventHandler(ehBeforeDebugStart);
commandEvents = null;
dte = null;
}
private void ehBeforeDebugStart(string Guid, int ID, object CustomIn,
object CustomOut, ref bool CancelDefault)
{
// Do stuff here before Debug.Start executes...
}

Signature
Best Regards,
Dustin Campbell
Developer Express, Inc
kehlar - 31 Oct 2005 16:22 GMT
Thanks! That's exactly what I was looking for.
One more question: where do you find the GUIDs for the command events?
Somehow my event handlers are not been called eventhough the commandEvents
object was created successfully and CommandEvents::DispEventAdvise was called
for it (I'm writing this in C++). I want to make sure that I have the right
GUID.
> > I would like to be able to intercept the F5 key so I can run some
> > operations before the debug session starts. Is there a way to do
[quoted text clipped - 32 lines]
> // Do stuff here before Debug.Start executes...
> }
Dustin Campbell - 31 Oct 2005 16:45 GMT
> One more question: where do you find the GUIDs for the command
> events? Somehow my event handlers are not been called eventhough the
> commandEvents object was created successfully and
> CommandEvents::DispEventAdvise was called for it (I'm writing this in
> C++). I want to make sure that I have the right GUID.
The easy way is to simply set up your CommandEvents handlers to watch
for *all* commands and then check the Guid parameter when the event
fires. You can do this by passing null and 0 when calling
"get_CommandEvents":
dte.Events.get_CommandEvents(null, 0);
Then, just fire the command you're trying to find the command group
(guid) and id for and watch the parameters.
The comprehensive way is to look in the "stdidcmd.h" file that installs
with the Visual Studio SDK (formerly known as the VSIP SDK). If you
look in this file, you'll see that there are really only two GUIDs that
are used for standard Visual Studio shell commands:
CLSID_StandardCommandSet97 (5efc7975-14bc-11cf-9b2b-00aa00573819) and
CMDSETID_StandardCommandSet2K (1496A755-94DE-11D0-8C3F-00C04FC2AAE2).
The comments and this file can show you what commands belong to which
command group.

Signature
Best Regards,
Dustin Campbell
Developer Express, Inc
kehlar - 31 Oct 2005 18:11 GMT
Thanks, that worked perfectly!
> > One more question: where do you find the GUIDs for the command
> > events? Somehow my event handlers are not been called eventhough the
[quoted text clipped - 20 lines]
> The comments and this file can show you what commands belong to which
> command group.