SendKeys

Description:

baSendKeys sends a series of keystrokes to the active window.

Platforms:

Windows and Macintosh

Usage:

Result = baSendKeys( Keys )

Arguments:

String.
Keys is the string of keys to send. See the notes section for a full description.

Returns:

Integer.
Returns an error code.

success

invalid character in string

window unavailable

unknown error

another SendKeys function is still under way

5 or 6 

security error. On later versions of Windows, you will need to turn UAC off to send keys to another application

Examples:

Director:
OK = baSendKeys( "hello" ) -- sends "hello"
OK = baSendKeys( "^C" ) -- sends Control C
OK = baSendKeys( "{F1}" ) -- sends the F1 key
OK = baSendKeys( "fname.txt{ENTER}" ) -- sends "fname.txt" then Enter

Authorware:
OK := baSendKeys( "hello" ) -- sends "hello"
OK := baSendKeys( "^C" ) -- sends Control C
OK := baSendKeys( "{F1}" ) -- sends the F1 key
OK := baSendKeys( "fname.txt{ENTER}" ) -- sends "fname.txt" then Enter
 

Notes:

The string sent can contain any alphanumeric character.

The keys sent will be case sensitive, and this may affect some programs. For example, sending "^C" may be interpreted by some programs as sending Control+Shift+c, others may treat it the same as "^c".

Use "@" for the Alt key, "~" for the Shift key, "^" for the Control key, and # for the Macintosh Command key

 If you need to send these actual keys, use a combination of Shift and the required letter eg to send "@" use "~2".

Other special keys can be sent as follows: (include the curly brackets)
 

{F1}, {F2}, etc to {F12}    {ENTER}
{INSERT}    {BKSP}
{DELETE}    {PRTSC}
{HOME}    {ESCAPE}
{END}    {LEFT}
{PGUP}    {RIGHT}
{PGDN}    {UP}
{TAB}    {DOWN}

Sending function keys is not supported on Macintosh.