Bookshelf Home | Contents | Index | Search | PDF |
Siebel VB Language Reference > Siebel VB Language Reference >
SendKeys Statement
This standard VB statement sends keystrokes to an active Windows application.
Syntax
SendKeys string[, wait]
Returns
Not applicable
Usage
The keystrokes are represented by characters of string.
The default value for wait is 0 (FALSE).
To specify an alphanumeric character, enter it in string. For example, to send the character a, use
a
as string. Several characters can be combined in one string: If string isabc
, then a, b, and c are sent to the application.To specify that the SHIFT, ALT, or CTRL key should be pressed simultaneously with a character, prefix the character with
Parentheses can be used to specify that the SHIFT, ALT, or CTRL key should be pressed with a group of characters. For example,
%(abc)
is equivalent to%a%b%c
.The following characters must be enclosed in braces if they are to be understood as literal characters by SendKeys; otherwise they have specific meanings as follows:
For example, a string equal to
{%}
specifies a literal percent character, %.Use
{{}
to send a left brace and{}}
to send a right brace.To send the same key several times, enclose the character in braces and specify the number of keys sent after a space. For example, use
{X 20}
to send 20 X characters.To send one of the nonprintable keys, use a special keyword inside braces:
To send one of the function keys (F1 to F15), simply enclose the name of the key inside braces. For example, to send F5, use
{F5}
.Note that special keywords can be used in combination with +, %, and ^. For example,
%{TAB}
means 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).
SendKeys cannot be used to send keys to an application that was not designed to run under Windows.
Example
This example starts the Windows Phone Dialer application and dials a phone number entered by the user.
Sub Button_Click
Dim phonenumber, msgtext
Dim x
phonenumber = 650-555-1212
x = Shell ("Terminal.exe",-1)
SendKeys "%N" & phonenumber & "{Enter}", -1
End SubSee Also
Bookshelf Home | Contents | Index | Search | PDF |
Siebel VB Language Reference Published: 18 June 2003 |