Global Send Keys and Global Send Key Events

Click this icon on the toolbar to view and download the full PDF version of this guide.

Global Send Keys and Global Send Key Events are text input methods for applications or elements that do not support other input methods, such as Write stages. The methods are:

  • Global Send Keys – Global Send Keys will work for most applications and should be tried before Global Send Key Events. This is a higher-level interface that sends keystrokes to the active application. Global Send Keys uses the .NET Framework SendKeys.SendWait(String) method, either with the whole string of keys parsed from the query, or the individual keys one at a time, separated by an interval if one has been specified. It will also check for control characters if a wait interval has been specified, and will throw an exception if found.
  • Global Send Key Events – Global Send Key Events work for all applications and is the method recommended for Citrix thin client applications. It is a lower-level interface that mimics keyboard keystrokes in the operating system. Global Send Key Events retrieve a set of virtual key codes obtained from the parameter specified in the action. The keys are then sent individually using the lower-level non-managed method keybd_event. After each keyboard event instruction is sent by Global Send Key Events, the target application thread which SS&C | Blue Prism® Enterprise uses to connect to the application will wait for the specified interval.

Global Send Keys and Global Send Key Events each use specific text formats. For more information, see Global Send Keys and Global Send Key Events syntax.

Unlike other interfaces where a Write stage will populate an element with text, even when that element is not visible, there are some factors that need to be in place for Send Keys to work:

  • The desktop screen must exist and be persistent. Send Key interfaces will not work if the desktop screen is locked or a screen saver is displayed.
  • The window that you want to send text to must be activated to be the topmost window of all running applications.
  • The element within the window you want to send text into must be in focus so that the keyboard cursor is in it and ready to enter text.
  • To ensure the application has time to react to any window or element focus navigation, short delays are required between window activates, element clicks, and using Send Keys.
  • To ensure text is entered correctly, a short delay should be configured between each keystroke. For some applications, entering text too quickly can result in some characters not being correctly entered.

You may need to implement additional logic in your processes to cater for the above factors. This will ensure that your solution will work reliably.

When to use Global Send Keys and Global Send Key Events

This functionality should be used when other methods of inputting text do not work, such as:

  • If a thin client technology, such as Citrix, is being used.
  • The element in an application cannot be identified by the Application Modeller.
  • The element in an application does not accept the use of a Write stage.

Unless using Citrix thin client applications, if one interface method of sending text to an application does not work, the alternative methods should be attempted in the following order:

  1. Write stage – Sending text using a Write stage uses technological interfaces specific for the application type.
  2. Windows Press Keys – For Windows based applications this action in a Navigate stage will work to send text. None of the window activation or element focus methods mentioned in this guide are required.
  3. Global Send Keys – This option should be tried before Global Send Key Events as it is a higher-level interface and easier to use special keys, such as Control.
  4. Global Send Key Events – This is the final option and should always work. It is the only option that will work when interfacing with Citrix thin client applications. Even where Global Send Keys work, this option can be useful for some use cases where a key needs to be held down whilst other actions are performed.

Using Global Send Keys

The Global Send Keys function relies on sending keystrokes to the application area that is currently in focus. Not all parts of an application can be focused on, although Blue Prism Enterprise may be able to spy them. Global Send Keys are configured using the Navigate stage.

The Navigate stage contains all the required actions to set up Global Send Keys:

  1. The Main Window of the application is brought into focus using the Activate Application action.
  2. The text box to send keystrokes to is made active by using a Global Mouse Click Centre action.
  3. The Global Send Keys action sends the data to the application. This uses the following input parameters: 
  4. The Pause After Each Step is the configured delay between each step. The appropriate value for an interface will depend upon the responsiveness of applications in your environment. This is typically between 0.25 and 1 seconds.

Using Global Send Key Events

The Global Send Key Events function sends keystroke events to the active application. This does not need to be the target application – keys are processed by whichever application is in focus. This differs from the Global Send Keys function, which sends keystrokes to the application that application modeller is currently attached to. Global Send Key Events uses a lower-level method of sending keys, and is therefore more likely to work with some applications.

Global Send Key Events are configured using the Navigate stage, with the text to be input configured using the Text parameter.

The above image demonstrates pressing a CTRL+S key combination. The order of key presses is:

  1. The key down signal (hold the key down)

  2. The code for the Control key

  3. The 's' key

  4. The key up signal (release the key)

  5. The Control key code as the key to be released

For details on the supported values and examples, see Global Send Keys and Global Send Key Events syntax.

A down keystroke for special keys must always be followed by a corresponding up keystroke.

Focusing applications

The application must have the current focus in order for Global Send Key Events to work, otherwise nothing is sent. To retain the focus when keys are being sent, it may be necessary to launch the window and then immediately send the keys as the next step.

A new Business Object may need to be created for connecting to the target application's main window, particularly if working with applications such as mainframe emulators. If you are trying to send keys to a mainframe session hosted within a mainframe emulator product, you will need a Win32 object to activate the emulator window and then send keys to that window, rather than to the underlying mainframe session.

Using Global Send Keys with SAP

SAP must be configured correctly in order for Blue Prism to automate it. Please refer to our SAP Integration Guide on the Blue Prism University for more information about this configuration.

Assuming SAP has been configured correctly, when using Global Send Keys for a SAPMainWindow in SAP version 7 or above, the text has to be an integer only value.

For a complete list of virtual keys that can be used with SAP, see the SAP website.

The list of keyboard shortcuts listed on the SAP website are only called when you send a SAPMainWindow element the corresponding integer value. An example of this is when sending F9 (which has the virtual key V9 as per the SAP documentation), the integer value that needs to be input into the Value field of the Navigate Stage is "9".