views:

41

answers:

2

Hi, I was getting tired of hitting the F10 every step to debug the programs. Are there any program can automate the visual studio to run each debugging step in a consistent frequency? say, 3 seconds for each step?

Regards, Sam

+2  A: 

You can easily do that with a simple script in Autohotkey.

Download it from here: http://www.autohotkey.com/

  1. Install Autohotkey.

  2. Run it.

  3. Find the green "H" icon in the task bar (bottom right).

  4. Right click the icon and select Edit script.

  5. And copy paste this script below.

^!y::
InputBox, input1, How many F10 strokes you want?, , , 250, 100
InputBox, input2, How many seconds between each F10 stroke?, , , 250, 100

if ErrorLevel <> 0
{
  MsgBox, CANCEL was pressed.
}
else
{
  loop, %input1%
  {
      Sleep, (input2 * 1000)
      Send {F10}
  }
  MsgBox, "Your F10 script has Ended"
}
return
  1. Then reload (again by right clicking the green "H" icon in task bar).

  2. Press Control+Alt+y to try out the above script.

bits
+2  A: 

Sitting there repeatedly hitting F10 can be annoying, but you probably just need to make more use of the inbuilt debugging features.

  • set a breakpoint at a targetted location and hit F5 to run the program, it will stop when it hits the breakpoint
  • use F11 to step in to a function
  • use Shift-F11 to step out of a function
  • use the breakpoints window (Debug->Windows->Breakpoints) to get a complete list of all the bp's and you can easily enable/disable any of them (or set any of their other options)
  • use the Exceptions window (Debug->Exceptions) to select exceptions that you want to break on when they are first thrown
  • familiarize yourself with the options available to breakpoints (right-click on the bp itself to get these)

    • hit count: specify how many times code should go past the breakpoint before it stops

    • condition: super useful (i use it all the time), you can use almost any expression in there, including checking the value of inscope variables

    • when hit: you can run a macro when the breakpoint is hit

    • filter: to restrict which running thread can break on that breakpoint

slugster