Use the Repeat commands to repeat a section or the entire macro any given number of times. All macro repeat loops must include an End Repeat command. All commands immediately following the Repeat command are repeated until an End Repeat command is encountered.
Script Editor > Expand Repeat Category > One of Repeat Commands in this Topic
The Start Repeat repeats a macro sequence the number of times requested. Enter the number of times to repeat the macro in the Number of Times to Repeat edit box.. Click on OK to save the settings. All macro commands after the Start Repeat are repeated until an End Repeat command is encountered.
Number of times to repeat
Insert the number of times to repeat the macro script.
Number to start counter on
This is currently only used in conjunction with a repeat counter. It specifies the starting point of the repeat counter.
Increment the counter by
This is currently only used in conjunction with a repeat counter. It specifies an increment to apply to the repeat counter each time the repeat loops.
Counter Start and Stop Example
Let's look at an example using the Counter Start and Counter Stop. If we set the counter start to 5 and the counter step to 10 and had a repeat count of 3 then a repeat counter would have the following values:
During the 1st of 3 loops: 5
During the 2nd of 3 loops: 15
During the 3rd of 3 loops: 25
Start Repeat with Prompt
Use the Start Repeat with Prompt option to repeat a script a variable number of times. When the macro reaches this command in the script during playback, a prompt window displays prompting the user to insert the number of times to repeat the macro. Enter the number and the macro string repeats the number of times requested.
Use this option to avoid having to rewrite or edit the macro each time a variable number of repetitions is required.
Start Repeat With Variable
The Start Repeat with Variable option repeats the macro based on the value saved to the Integer variable selected. If the value of the Integer variable is 10, the macro is repeated 10 times.
Repeat using variable
Insert the Integer variable name in this field or click on the Variable button to select the variable previously defined.
The Repeat Until option repeats a macro script again and again until a condition is met. The condition is the comparison of a text, integer or decimal variable to a fixed value. Comparisons can be equal, not equal, less than, greater than, less than or equal to or greater than or equal to. The comparison can also check to see if the variable contains or does not contain a specific text string, number, decimal, etc.
One example of this function is to create a macro that copies a line of text to the clipboard and then saves the clipboard contents to a variable. The Repeat Until function looks for a specific string of text. If the string of text is found, the macro breaks out of the Repeat loop and continues with the rest of the macro. If not, the macro moves to the next line in the document and repeats the process.
This option is also a way to run a macro continuously. For example set the Repeat Until option to repeat until N = 1. Then do not insert any code in the macro to allow variable N to equal 1.
Sample Macro - Repeat Until
In this example, we want to make sure that Microsoft Word is closed before the macro continues. The command to close Word must be placed before the macro commands listed below.
Variable Set Integer %N% to 0
Repeat Until %N% = 1
If Not Program Name "Word" running
Variable Set Integer %N% to 1
üNote: The macro commands between the Repeat Until and Repeat End commands are always executed at least once, because the Until condition is not evaluated until after the first iteration.
Repeat With Folder
This command scans through a folder and finds each file or subfolder in the folder. During the repeat process each successive file name or subfolder is placed in a text variable which can then be processed by other macro commands.
Sample Macro - Repeat with Folder
This macro counts the number of files in a particular folder. The count is saved to variable N. Before starting the repeat loop, Integer variable N is set to 0. Each time the macro repeats through the files, N is incremented by one until a final count is made. After the loop is completed, a Text Box Display command has been added to display the file count.
Variable Set Integer %N% to 0
Repeat with Folder
Variable Modify Integer: %N% = %N% + 1
Text Box Display: Files in folder
Select the folder to be processed. Either enter the path name directly or use the Browse button to locate the folder.
Choose whether to return files only or folders.
Place Result In
Select the variable that will store the file or folder name.
Return the Full File Path
Use this option to save the full file path to the variable. Otherwise
Process Sub Folders
Optionally choose to have the macro recursively process all subfolders. This places all the file names or sub folders that are located in the folder or subfolders being processed into the variable.
Repeat with Windows
The Repeat with Windows command is similar to the Repeat with Folder command. It scans through all of the windows running on the computer, both visible and hidden. During the repeat process each successive window title is placed in a text variable which can then be processed by other macro commands.
Windows to Retrieve
Select whether to process through all windows, visible windows or hidden windows.
Select whether to process the windows alphabetically or in the order the windows are saved by the operating system.
Place Titles in
Select the Text String variable to store the value of the window title.
Repeat with Processes
This command is also similar to the Repeat with Folder command. Repeat with Processes loops through all processes currently running on the computer. During the repeat loop the name of each successive process is placed in a text string variable which can then be acted upon by other macro commands.
üNote: Running processes are displayed in the Windows Task Manager.
Store the Counter into a Variable
For the Start Repeat, Start Repeat with Prompt and Start Repeat with Variable commands, optionally place the repeat counter into a variable so that the counter value can be used and manipulated during the repeat process.
1. Repeat commands can be nested (placed inside of each other).
2. Repeat commands can cause excessively long macros. Remember, there is a way to abort a macro! Press the Scroll Lock and Pause buttons to stop the macro.