Previous Topic

Next Topic

SendKeys - MaxBasic Function

SendKeys(Keys: String[, Delay: Number)

Send Keys function sends the keystrokes for the Keys string to the active window. If a Delay number is entered, has a delay of Delay milliseconds between keys.

SendKeys function syntax has these named arguments:

Parameter

Description

Keys

Required. The string of keystrokes to be sent to the active window.

Most ASCII characters can be represented by the character itself. E.g. the key sequence FRED can be represented by "FRED".

Some special keys, such as the control keys, function keys etc are encoded in a string enclosed by {braces}.

See the table below.

Delay

Optional. If entered, there will be a delay of Delay milliseconds between keys.

Key/Character

SendKey

Description

~

{~}

Send a tilde (~)

!

{!}

Send an exclamation point (!)

^

{^}

Send a caret (^)

+

{+}

Send a plus sign (+)

Backspace

{BACKSPACE} or {BKSP} or {BS}

Send a Backspace keystroke

Break

{BREAK}

Send a Break keystroke

Caps Lock

{CAPSLOCK}

Press the Caps Lock Key (toggle on or off)

Clear

{CLEAR}

Clear the field

Delete

{DELETE} or {DEL}

Send a Delete keystroke

Insert

{INSERT} or {INS}

Send an Insert keystroke

Cursor control arrows

{LEFT} / {RIGHT} / {UP} / {DOWN}

Send a Left/Right/Up/Down Arrow

End

{END}

Send an End keystroke

Enter

{ENTER} or ~

Send an Enter keystroke

Escape

{ESCAPE}

Send an Esc keystroke

F1 through F12

{F1} through {F12}

Send a Function keystroke

Home

{HOME}

Send a Home keystroke

Numlock

{NUMLOCK}

Send a Num Lock keystroke

Page Down

Page Up

{PGDN}

{PGUP}

Send a Page Down or Page Up keystroke

Print Screen

{PRTSC}

Send a Print Screen keystroke

Scroll lock

{SCROLLLOCK}

Press the Scroll lock Key (toggle on or off)

TAB

{TAB}

Send a TAB keystroke

To specify keys combined with any combination of SHIFT, CTRL, and ALT keys, precede the key code with one or more of the following:

For SHIFT prefix with +

For CTRL prefix with ^

For ALT prefix with %

Example with modifier keys:

const Ctrl = "^"

const Alt = "%"

const Shift = "+"

SendKeys(Ctrl & Alt & Shift & "A")

SendKeys(Ctrl & "A"). ' select all text in the script editor

SendKeys(Ctrl & Shift & "I") ' indent all text in the script editor

See Also

Script Functions

Book Contents

Book Index