Skip to main content
OCLC Support

SendKeys

Find the syntax, use, parameters, return values, and an example for the SendKeys macro command in Connexion client.
Syntax CS.SendKeys string$ [, wait%]
Use to Send keystrokes to the client.
Parameters
  • For string$, enter an expression containing the characters to send. See the comments for how to represent keystrokes with characters.
  • For [, wait%], enter a numeric expression to determine whether to wait until all keys are processed before continuing program execution:
    • -1 = wait
    • 0 = do not wait (default)

Both parameters are required.

Recommendation OCLC recommends that you precede a CS.SendKeys string in a macro with an empty CS.SendKeys string to help stabilize the way SendKeys works.

Example:
Dim CS As Object
Set CS = GetObject(,“Connex.Client”) CS.SendKeys ““, -1
CS.SendKeys “{(}abc{)}”, -1Sends the keys (abc)
Comments
  • To specify an ordinary character, enter it in the string. For example, to send character 'a' enter "a" as string. Several characters can be combined in one string: string "abc" means send 'a', 'b', and 'c'.
  • To specify that Shift, Alt, or Control keys should be pressed simultaneously with a character, prefix the character with:
    • + to specify Shift
    • % to specify Alt
    • ^ to specify Control
  • Parentheses can be entered to specify that the Shift, Alt, or Control key should be pressed with a group of characters. For example, "%(abc)" is equivalent to "%a%b%c".
  • Since '+', '%', '^' ,'(' and ')' characters have special meaning to SendKeys, they must be enclosed in braces if they need to be sent with SendKeys. For example, string "{%}" specifies a percent character '%'.
  • The other characters that need to be enclosed in braces are:
    • Tilde (~) which stands for a new line
    • Enter if used by itself
    • Braces - Enter {{} to send { and {}} to send }.

    Brackets ([ ]) do not have special meaning to SendKeys but might have special meaning in other applications; therefore, they also need to be enclosed inside braces.
  • To specify that a key needs to be sent several times, enclose the character in braces and specify the number of keys sent after a space.
    Example: Enter {X 20} to send 20 'X' characters.
  • To send one of the non-printable keys, enter a special keyword inside braces, as shown in the list below.
  • To send one of function keys F1 through F12, enclose the name of the key inside braces. For example, to send the F5 key, enter "{F5}".
  • Note that special keywords can be entered in combination with +, %, and ^. For example: %{TAB} represents Alt-Tab. Also, you can send several special keys in the same way as you would send several normal keys: {UP 25} sends 25 Up arrows.
  • SendKeys can send keystrokes only to the currently active application. Therefore, you have to use the AppActivate statement to activate an application before sending keys (unless it is already active). See OML Help for more information about AppActivate.
  • SendKeys cannot be used to send keys to an application that was not designed to run under Windows.
Return values None
Example Sub Main()
 

     Dim CS As Object
     Set CS = GetObject(,“Connex.Client”)

     CS.SendKeys ““, -1
     CS.SendKeys “{F1}”, 0
End Sub

What this example does
  • Sends an empty SendKeys string (see recommendation above).
  • Sends the F1 function key to the client to open Help. F1 is the default keystroke assigned to open Connexion Client Help.

 

Keywords used to send non-printable keys

Key Keyword
Backspace {BACKSPACE} or {BKSP} or {BS}
Break {BREAK}
Caps Lock {CAPSLOCK}
Clear {CLEAR}
Delete {DELETE} or {DEL}
Down Arrow {DOWN}
End {END}
Enter {ENTER}
Esc {ESCAPE} or {ESC}
Help {HELP}
Home {HOME}
Insert {INSERT}
Left Arrow {LEFT}
Num Lock {NUMLOCK}
Page Down {PGDN}
Page Up {PGUP}
Right Arrow {RIGHT}
Scroll Lock {SCROLLLOCK}
Tab {TAB}
Up Arrow {UP}