Friday, June 29, 2012

How to Record and Play macro in Visual Studio

Macro comes in very handy if you have to repeat certain operation a lot of times.

Ctrl + Shift + R => Start
Ctrl + Shift + R => Stop
Ctrl + Shift + P => Play

I recently learned about them when i needed to put breakpoint on all the calls to function(SendEvent) and inspect the event id. At first i was manually putting the breakpoint but then i realised that the file was like 3K lines of code. So, instead what i did was search for "SendEvent" once and then after that pressing F3 will move to next occurrence of the searched string. Then move to the start of the file. Press Ctrl+Shift+R to start recording macro, press F3 to get to first matched string and then press F9 to put the breakpoint.  Press Ctrl+Shift+R to stop recording. Then keep pressing Ctrl+Shift+P till the end of the file.