The sendKey function is used to send either a keystroke or a string of keystrokes to the host presentation space.
You define the string of keystrokes to be sent with the calling data string parameter. The keystrokes appear to the target session as though they were entered by the terminal operator. You can also send all attention identifier (AID) keys such as Enter and so on. All host fields that are input protected or are numeric only must be treated accordingly.
Prerequisite Calls
connectPresentationSpace
Call Parameters
Parameter name
|
Explanation
|
key
|
A string of keystrokes, maximum 255. Uppercase and lowercase ASCII characters are represented literally. Function keys and shifted function keys are represented by mnemonics. See Keyboard Mnemonics.
|
Return Properties
Property name
|
Explanation
|
returnCode
|
A numeric code indicating the execution status of the function. Please refer to the Return Code table below for all possible values.
|
Return Code
The following values are defined for the 'returnCode' property:
Return Code
|
Explanation
|
0
|
The keystrokes were sent; status is normal.
|
1
|
Your program is not connected to a host session.
|
Remarks
1. | This function is equivalent to HLLAPI Function Number 3. |
2. | The parameters under the 'params' property are related to this function. They are the AUTORESET/NORESET, STRLEN/STREOT, EOT=c, ESC=c, and RETRY/NORETRY session options. |
3. | Keystrokes cannot be sent to the host session when the keyboard is locked or busy. You can check this condition with the wait function. |
4. | If the host is busy, input might be rejected. |
5. | To send special control keys, a compound character coding scheme is used. In this coding scheme, one keystroke is represented by a sequence of two to four ASCII characters. The first and third character are always the escape character. The second and fourth character are always a keycode. To send the sequence LOGON ABCDE followed by the Enter key, you would code the string LOGON ABCDE@E. A complete list of these keycodes is represented in Keyboard Mnemonics. This compound coding technique allows an ASCII string representation of all necessary keystroke codes without requiring the use of complex hexadecimal key codes. The default escape character is @. The value of the escape character can be changed to any other character with the ESC=c option of the 'params' property. |
6. | Users needing higher levels of performance should use the copyStringToField or copyStringToPresentationSpace function rather than send keystrokes with the sendKey function. But remember, only the sendKey function can send the special control keys. |
7. | Refer to session NORESET option to improve the performance of this function. Unless NORESET is required, the reset mnemonic is added to the keystroke strings as a prefix. Therefore, all resettable status except input inhibit are reset. |
8. | The keystroke strings, including the AID key, are sent to the host via multiple paths. Each path sends the strings before the first AID key (or including the AID key). HLLAPI adjusts the string length and the start position of each path. For a host application program, any keystroke might be lost by the AID key process. Therefore, you should not send a keystroke list that includes plural AID keys. |
9. | During the @P (Print) or @A@T (Print Presentation Space) process, all requests that update the presentation space are rejected. If the presentation space is busy or the interruption request occurs during the print request, the mnemonic @A@R (Device Reset - Cancel to print the Presentation Space) cancels the request and resets the status. |
|