SendKeys (statement)


SendKeys KeyString$ [,[isWait] [,time]]


Sends the specified keys to the active application, optionally waiting for the keys to be processed before continuing.


The SendKeys statement accepts the following parameters:






String containing the keys to be sent. The format for KeyString$ is described below.



Boolean value.

If TRUE, then the Basic Control Engine waits for the keys to be completely processed before continuing.

If you are using SendKeys in a CimEdit/CimView script, you must set this flag to TRUE. If you do not, when a user tries to execute the SendKeys statement, the CimView screen freezes and processing will not continue.

If FALSE (or not specified), then the BasicScript continues script execution before the active application receives all keys from the SendKeys statement.



Integer specifying the number of milliseconds devoted for the output of the entire KeyString$ parameter. It must be within the following range:

  0 <= time <= 32767

For example, if time is 5000 (5 seconds) and the KeyString$ parameter contains ten keys, then a key will be output every 1/2 second. If unspecified (or 0), the keys will play back at full speed.


Specifying Keys

To specify any key on the keyboard, simply use that key, such as "a" for lowercase a, or "A" for uppercase a.

Sequences of keys are specified by appending them together: "abc" or "dir /w".

Some keys have special meaning and are therefore specified in a special way, by enclosing them within braces. For example, to specify the percent sign, use "{%}".

the following table shows the special keys:



Special Meaning














Shortcut for Enter










No special meaning


'Open bracket



Used to enclose special keys


'Up Arrow



Used to specify grouping


'Ctrl+A, Ctrl+B


Keys that are not displayed when you press them are also specified within braces, such as {Enter} or {Up}. A list of these keys follows:






















































{Scroll Lock}




















Keys can be combined with Shift, Ctrl, and Alt using the reserved keys "+", "^", and "%" respectively:

For Key Combination Use

Shift+Enter "+{Enter}"
Ctrl+C "^c"
Alt+F2 "%{F2}"


To specify a modifier key combined with a sequence of consecutive keys, group the key sequence within parentheses, as in the following example:

For Key Combination Use

Shift+A, Shift+B "+(abc)"
Ctrl+F1, Ctrl+F2 "^({F1}{F2})"


Use "~" as a shortcut for embedding Enter within a key sequence:

For Key Combination Use

a, b, Enter, d, e "ab~de"
, Enter "~~"


To embed quotation marks, use two quotation marks in a row:

For Key Combination Use

"Hello" ""Hello""
a"b"c  "a""b""c"


Key sequences can be repeated using a repeat count within braces:

For Key Combination Use

Ten "a" keys "{a 10}"
Two Enter keys "{Enter 2}"


This example runs Notepad, writes to Notepad, and saves the new file using the SendKeys statement.

Sub Main()

   Dim id As Variant

   id = Shell ("notepad.exe")    'Run Notepad minimized

   AppActivate id                'Now activate Notepad

   AppMaximize                   'Open and maximize the Notepad window

   SendKeys "Hello Notepad", 1   'Write text with time to avoid burst

   Sleep 2000

   SendKeys "%fs", 1             'Save file (Simulate Alt+F,S keys)

   Sleep 2000

   SendKeys "name.txt{ENTER}", 1 'Enter name of file to save


End Sub







More information