SendKeys method
Use the SendKeys method to send a key command to a control. The Sendkeys method relies on native injection to work. You can use this method to interrogate controls on the webpage that is being displayed, such as Refresh, Minimize, and Maximize.
Note: If you are automating the Google Chrome or Mozilla Firefox browsers, the SendKeys method is only available for the Web and Universal Web Adapter in version 19.1.14.0 and later.
See the sample automation for an example using the SendKeys method. This method has two parameters, as shown in this design block:
Use the Keys parameter to send key values or commands:
Send a keyboard value by typing the value. For example, send the text ATL to a control by typing ATL in the Keys parameter.
Send keyboard command by enclosing
the command in curly brackets. For example, send the Tab keyboard
command by typing {TAB} in the keys parameter. For more
information, see Keyboard command list.
Note: The plus sign (+), caret (^), percent sign (%), tilde
(~), and parentheses () have special meanings to this method. To send
any of these as literal characters, enclose the character in braces.
For example, to send the plus sign, enter {+} for the command.
Enclose each bracket in braces {[}, even though the square brackets [ ] do not have a special meaning to the SendKeys method.
Specify keys combined with any combination of the Shift, Ctrl, and Alt keys by preceding the key code with one or more of the following codes.
Key |
Code |
Shift |
+ |
Ctrl |
^ |
Alt |
% |
Specify that any keypress combination of Shift, Ctrl, and Alt should be held down while several other keys are pressed and enclose the code for those keys in parentheses. For example, to specify to hold down Shift while the E and C keys are pressed, use +(EC). To specify to hold down Shift while the E key is pressed, followed by C without Shift, use +EC.
In the Text adapter, there are methods defined for specific keys to be pressed, such as F3 and Enter, or you can use SendKeys(WinHllapiKey key). The SendKeys(string keys) method does not support the {xxx} format. Send plain text with the SendKeys(string) method.
Specify repeating keys by using the form {key number}. You must put a space between key and number. For example, {LEFT 42} means press the left arrow key 42 times.
Use the Focus parameter to specify whether the control should receive focus when the key or command is sent. This parameter is usually set to True to focus the control.
Privacy | Trademarks | Terms of Use | Feedback
Updated: 01 July 2024
© 2016 - 2024 Pegasystems Inc. Cambridge, MA All rights reserved.