Run Action Icon

Run Action

Declaration

<AMRUN FILE="text" SINGLEINSTANCE="yes/no" WAITFORINPUT="yes/no" WAITFOREND="yes/no" RESULTVARIABLE="text" WINDOWCLASSVARIABLE="text" WINDOWTITLEVARIABLE="text" WINDOWHANDLEVARIABLE="text" WINDOWSTARTUP="text [options]" DEFAULTFOLDER="text">

See Also

Print, End Process, Close Window, Send Keystrokes, Open Web Page

Description

Runs the program or document specified. If a document is specified, the application associated with the document will be used to open it.

Practical Usage

Run is one of the most commonly used actions in AutoMate. The most common usage of the Run Action is to start an application or open a document in preparation to send keystrokes, mouse clicks or other interactive steps immediately afterward. The Run <AMRUN> action has built in conveniences such as waiting for the application to be ready for input (finished loading) before moving on to the next step and a built in start menu for easy selection of the application. Remember that you can also specify documents in this action so for many applications it is not necessary to first start the application, then use send keystrokes to open the document as it can all be done in this one step.

Parameters

General Tab

Run
Text, Required
MARKUP:
a) FILE="C:\WINNT\system32\NOTEPAD.EXE"
b) FILE="C:\WINNT\system32\NOTEPAD.EXE &quot;C:\Program Files\Unisyn Software\AutoMate 5\readme.txt&quot;"

Specifies the command line to run. This parameter should specify the full path and file name to the EXE,COM,BAT, or CMD file you wish to run. To specify a document, use the browse button or "start menu" emulator and select the document. The properly formatted command line including the associated application the document will be automatically built.

Run only if another instance is not running
Yes/No, Optional - default NO
MARKUP: SINGLEINSTANCE=YES

Specifies that the program specified on the Run [FILE] parameter should not be run if another instance it is running on the current system already. If another instance is running when this option is enabled, the step will be ignored and it will not generate an error.

Advanced Tab

Wait until application is ready for input before continuing
Yes/No, Optional - default YES
MARKUP: WAITFORINPUT="NO"

When Yes, specifies that the step should wait until the application is detected to be finished loading and is ready to receive input such as keystrokes or mouse clicks. Not enabling this parameter could result in the task moving to the next line too early which would cause any Interactivity steps to be send into nothing (the application would not be loaded yet). Note: If the "Wait until application ends before continuing" [WAITFOREND] parameter is set to Yes then this parameter is ignored.

Wait until application ends before continuing
Yes/No, Optional - default NO
MARKUP: WAITFOREND="YES"

When Yes, specifies that the step should wait until after the application has either closed itself (in the case of batch files, scripts or console applications) or is closed by the user.

Application Return Code Variable
Variable, Optional - default (empty)
MARKUP: RETURNCODEVARIABLE="variablename"

When a variable is named, It will be populated with the application provided return code open termination of the application. Note: This parameter is only available when the "Wait until application ends before continuing" [WAITFOREND] parameter is "Yes". Not all applications use return codes, so the functionality of this action may vary from application to application.

Default Folder
Text, Optional - default (the folder of the application specified in Run)
MARKUP: DEFAULTFOLDER="C:\Program Files\Unisyn Software\AutoMate 5\"

Certain applications require a startup folder. This option is not required and is available primarily for legacy (older) applications. When not specified, the folder that the application resides in is used.

Window Tab

Populate variable with window class
Yes/No, Optional - default YES
MARKUP: WINDOWCLASSVARIABLE="myvarname"

When a variable is named, It will be populated with the Window Class of the application that is launched. Note: This parameter is only available when the "Wait until application is idle before continuing" [WAITFORINPUT] parameter is "Yes".

Populate variable with window handle
Yes/No, Optional - default NO
MARKUP: WINDOWHANDLEVARIABLE="myvarname"

When a variable is named, It will be populated with the Window Handle (which is a unique number) of the application that is launched. Note: This parameter is only available when the "Wait until application is idle before continuing" [WAITFORINPUT] parameter is "Yes".

Populate variable with window title
Variable, Optional - default (empty)
MARKUP: WINDOWTITLEVARIABLE="myvarname"

When a variable is named, It will be populated with the Window Title of the application that is launched. Note: This parameter is only available when the "Wait until application is idle before continuing" [WAITFORINPUT] parameter is "Yes".

Window Startup
Text, Optional - default "normal"
MARKUP: WINDOWSTARTUP="minimized"

Specifies whether the application’s window should be normal, hidden, maximized, or minimized when it starts.

The following text may be used as a value in this parameter:
normal
: The application will start normally
maximized
: The application will be requested to start maximized
minimized
: The application will be requested to start minimized
hidden
: The application will be requested to start hidden

Notes

Provided "Start Menu" Emulator
When in visual mode, a "start menu" emulator is provided on action properties for easy selection of the application/document from a menu that is based on your Windows start menu configuration. When a document (as opposed to an EXE file) is specified using either the start menu or the browse dialog -- the associated application is automatically detected, retrieved and a properly formatted command line is built and inserted. When specifying a document (as opposed to an EXE file). It is advisable to use this automatically constructed command line.

DOS Applications
DOS applications and certain console applications may not function correctly with the "Wait until application is ready for input before continuing" [WAITFORINPUT] parameter. This is because these applications do not support standard Windows event messaging that enables this kind of integration. For these applications, you may need to use a "Pause" <AMPAUSE> action or other method of waiting for the application to be ready from input.

Standard Error Handling Options
This action also includes the standard "Error Causes" and "On Error" failure handling options/tabs

More on Error Handling Options

Variables and Expressions
All text fields allow the use of expressions by surrounding the expression in percentage signs (example: %MYVARIABLE%, %Left('Text',2)%). To help construct these expressions, a popup expression builder is available in all these fields by pressing F2.
More on variables...

More on expressions...

More on the expression builder...

Example

<AMRUN FILE="C:\WINNT\system32\NOTEPAD.EXE">