Home > FAQ > Running Scripts

Running Scripts

Can I stop a script while it is running?

Yes, press Control+Shift+Pause key combination, the execution stops after the current line has finished executing.

Can I pause the script while it is running?

Yes, run the script in Debug mode (menu Debug/Start/Continue debugging) and insert a breakpoint in front of the line where to pause (menu Debug/Toggle breakpoint). To resume execution, press F5 (Debug mode is not available in WinTask Lite).

Can I run a script in background?

As soon as interactive actions are recorded in the script, it is not possible to run in background. For example, Windows needs a focused window for typing text into it. A script without interactive actions (for example file copy actions or ftp actions) can run in background. However, you can run a script in a minimized virtual machine and then scripts run while you use the PC for other tasks.

Can I create a subroutine that is run when an unexpected window appears?

Yes, OnAction statement can launch the desired subroutine when an unexpected window is displayed. See OnAction help article.

How can I run several scripts one after another?

Use Run function. See Run help article.

Can I create a subroutine that is run when an unexpected window appears?

Yes, OnAction statement can launch the desired subroutine when an unexpected window is displayed. See OnAction help article

How can I run several scripts one after another?

Use Run function. See Run help article.

In a suite of executions, how can I run the script n even if the script n-1 failed?

Use Run function, OnAction Error and End function. See Run help article for a full example.

Can I run multiple scripts at the same time?

No due the way Windows works: imagine script1 running notepad and sending keystrokes to notepad – but script2 starts running wordpad and sending keystrokes to wordpad. If script1 has put the focus to notepad window, script2 will send its keystrokes to notepad window instead of wordpad window.
 
But you can run multiple scripts at the same time using virtual machines.

When I replay my script, nothing happens, it just hangs. What is wrong?

When an error occurs during script execution, an error message is displayed after a default timeout of 30 seconds. If a Pause block fails, the default timeout is 120 seconds. If a script execution hangs without any message, that means that you changed this default behavior – check that you don’t have a line #IgnoreErrors=1 or a OnActionError block, as those prevent error messages to be displayed.

How can I increase the script execution speed?

You can increase script execution speed following the recommendations in Controlling Script Execution Speed help topic.

How can I launch a script execution from an external program?

You can use TaskExec module to launch a script execution. The command line is given in Running a script from the command line help topic. The software must be installed on the device where the command line is executed, or at least the WinTask runtime.

How can I send a mail if my script failed?

You can use OnAction Error and SendEmail function. See OnAction Error help article. SendEmail function is available only in WinTask x64.