Adding Functionality to Existing Scripts
Automation scripts require general maintenance and updating, as does all software. A script may need to be updated in response to a new release of the target application or changes to the target web page. You may need to take advantage of new features in the application. Or you may be trying to debug a new script that fails to execute to completion.
Recording mode can be used to quickly generate only the required changes instead re-recording the entire process from beginning to end. The following steps illustrate how you can add functionality to an existing script.
- Start WinTask x64. If the "Your First Script Wizard" dialog box is displayed, click the Close button. The WinTask x64 Editor window should now be active.
- Open the script to be modified in the WinTask x64 Editor.
- Manually type in the Stop statement at the location where the new functionality is to be added. If debugging a script, you may want to place the Stop either before or after the statement that fails during playback. Generally, if the failing statement provides synchronization (UseWindow, UsePage), place the Stop before the statement. If the statement performs an action (SendKeys, ClickHTMLElement), place the Stop after the statement.
- From the WinTask x64 toolbar, click the Play button . You are prompted to save the script. The Compiler is launched, and if no compilation errors are detected, your script starts running.
- The script will continue to execute until the Stop statement is reached. The script terminates and leaves the target application or web page in the correct state to start recording the required changes.
- Return to the WinTask x64 Editor. Insert a blank line above the Stop statement inserted by Step 3. Leave the insertion cursor at the beginning of the line.
- From the WinTask x64 toolbar, click the Rec button to start recording your actions.
- The "Start Recording Mode" dialog box will appear asking "What do you want to start before recording?". Select the Nothing radio button and click the OK button.
- Restore focus to the target application. Manually execute the new process or corrections to be inserted into the script. Use the Spy Tool to help identify internal window names or HTML Elements.
- Stop Recording Mode by clicking the Stop button on the floating WinTask x64 toolbar. The Stop button is the first button on the left side of the toolbar with the "X and rectangle" icon.
- The generated script statements are inserted into the existing script above the Stop statement. Review the new statements and remove any unneeded actions or actions that were made in error. Comment out the Stop statement for now.
- From the WinTask x64 toolbar, click the Play button. The script is saved and re-compiled and starts running.
- If the new functionality was added correctly, the script should run to completion performing all of its original tasks plus the new task(s).
- If the script still has problems, determine if any of the new script statements fail and need correction. Uncomment and reposition the Stop statement as needed. Repeat Steps 4 through 13 until the script performs all of its required tasks correctly.
- Once the script is fully functional, delete the Stop statement and re-compile the script. The script is now ready for production!