Editor Menu - Debug
Test Run Macro
Press the Test Run button on the tool bar, press F9 or click through the menu option to test run the macro open in the Editor. This is a quick way to determine if any fine tuning is necessary. Before the macro starts, a dialog similar to the one shown below is displayed. Choose whether to test run the macro in a specific window or leave focus as is.
Which window to use will depend on the first line or two of the macro.
For example if the first line of the macro types text, then select a window from the list where the text can be inserted. The macro needs to know where to type the text during the debug testing. With the (Don't Switch Focus) option the macro will attempt to insert the text into Macro Express, since this is the window that currently has focus.
If the macro does not use mouse clicks or type text before opening a program or window, then choose the (Don't Switch Focus) option. Or if the first line of the macro is to open a program or window and then insert text, use the (Don't Switch Focus) option as the macro will determine the focus.
Turning off the Switch Focus menu option, discussed below, will run the macro without opening the Start Debugger in a Different Window dialog.
Pause (Script Editor Only)
While the macro is running in test run mode click on Debug > Pause or the Pause button on the tool bar. This pauses the test run of the macro. Click on the Test Run button to resume.
Stop (Script Editor Only)
While the macro is running in test run mode, click on Debug > Stop or the Stop button on the tool bar. This stops the test run of the macro.
Toggle Breakpoint (Script Editor Only)
Highlight a line in the script to set as a breakpoint and then select the Toggle Breakpoint menu option or press CTRL B. When test running a macro, the macro stops at the set breakpoint. During the break, it's possible to view the Variables window (Debug > Show Variable Values from the menu) and verify that the variables are being populated correctly.
Press the Test Run Macro button to resume until finished or until the next breakpoint. To remove a Breakpoint, highlight the command in the script and press CTRL B or click on the menu item Debug > Toggle Breakpoint.
üNote: The breakpoints are saved when the macro is saved and are available for use the next time the macro is run through the debugger. The breakpoints are ignored when running the macro outside of the debug mode.
Step Options (Script Editor Only)
Select the Step Over or Step Into option to test run the macro and have the macro pause after each line in the script. Pressing the F8 or F7 button causes the macro to run the next command and so on, until the macro has finished. This simplifies the process for debugging a macro.
Step Into - F7
If the script contains a Macro Run command, pressing the F7 key or clicking on the Step Into button loads the script of the called macro into the editor and steps through each line of the called macro script.
Step Over - F8
If the script contains a Macro Run command, pressing the F8 key or clicking on the Step Over button plays the called macro at the appropriate point in the script, but does not step through the called macro.
Switch Focus (Script Editor Only)
When using the F7 or F8 key to step through a macro, it is necessary to click the mouse to return focus to the Editor between each step. In order to avoid this, select the Switch Focus option. The focus returns to the prior window when stepping through a macro.
Save Before Test Run
This option saves the macro script first and then performs a test run of the macro.
Show Variable Values
The values of the variables are displayed in a separate window when debugging a macro. Use this window to determine that the correct values are being saved to the variables. The window displays the variable type, variable name and the corresponding value.
Click on Debug > Show Variable Values or press the F5 key to open a window similar to the one displayed below. Give focus back to the Script Editor, press F7, F8, F9 or click on the Test Run button to run the macro in a test mode and watch the window populate with the variable values. Running in test mode again clears the values and repopulates the window with new data as the macro runs.
Helps for Debugging Macros
1. Did the macro run or not?
Depending on the macro, it may be difficult to determine whether the macro started and just played back incorrectly or never started at all. One method to help determine this would be to place a Sound File command at the beginning of the macro. The sound alerts when the macro starts.
Or log the commands and check the log file later to see if the macro at least started. This would be beneficial for debugging Scheduled macros, where you may not be around when the macro is set to run.
2. Variables
If you are seeing odd values being used in the macros, you may need to check what values are being saved to variables. One method to do this would be to use the Text Box Display command to show what values are saved to each variable.
If a variable value is not correct, you can look to see if the wrong field is being copied and saved to a variable, not enough time was allowed to copy the value or any number of other causes.
3. Timing
Timing may cause a macro to fail or to do unexpected things. Macro Express has quite a few options to help. Below are several of the more common timing commands.
a)Wait for Window Title instructs the macro to wait for the window to be ready to accept mouse or keyboard input before continuing.
b)Delay adds a delay of a specified duration to allow Windows or the application to be ready before accepting additional macro commands.
c)Wait for Text Playback instructs the macro to not continue until all of the text from a Text Type command has been typed. This is useful for longer strings of text.
d)Keystroke Speed slows down the playback of text in situations where the receiving application has difficulty high speed input.
e)When capturing (recording) a macro, the Macro Speed command is inserted in the first line of the macro script. Adjust the speed value to slow down or speed up the macro playback.