Sending Keystrokes to an Application

You can send keystrokes to an application by using a script.

General Approach

To send keystrokes to an application, you must::

All of the solutions described here use the SendKeys method. This method cannot target a specific application or window—it just sends the keystrokes to whatever window is active. Therefore you must make sure you have activated the appropriate window first, or you will be sending keystrokes to the wrong application.

Specific Approach

The approach will vary depending on the circumstances, as described in the following sections.

Sending keystrokes to an application started by adTempus

A common situation is where you have launched an application using a Program Execution task, and then need to send keystrokes to the application to tell it to run a macro or do whatever processing is necessary.

In this case the simplest approach is to create a Script Action attached to the appropriate event. For example, if you want to send the keystrokes immediately after the application is started, attach the action to the step's "Task started" event.

To send the keystrokes, just use the SendKeysToTargetApplication function defined in the Builtin script library. This function activates the correct window and sends the keystrokes.

Note that this approach can only be used within a step that executes a Program Execution Task; the SendKeysToTargetApplication function will not work in any other circumstances.

Sending keystrokes to an application started outside of adTempus

To send keystrokes to an application that was not started by an adTempus Program Execution task (or to an application that was started with a Program Execution task, but not within the current step) you can use a Script Action or a Script Execution Task to execute the script at the appropriate time.

To send keystrokes to the application you will need to know its title—the exact title that appears in the window's title bar. Then use the SendKeysToWindow function defined in the Builtin script library. This function activates the correct window and sends the keystrokes.