Msg

From Br Wiki
Jump to: navigation, search
MSG("<KB>",<string>) ! send string to keyboard

The MSG internal function (without the dollar sign) is only available for Windows & CS versions. This should not be confused with Msg$. For example:

MSG("sleeptime",centiseconds) ! specify MSG keystroke time interval (100 = 1 Second)

With the Msg internal function you can directly control the keyboard under the Windows client from within a BR program by issuing a function call to MSG.

Msg is useful for redisplaying Windows menus upon returning to a menu program from an application program. MSG has no effect on Unix or Linux terminal sessions, but works under Client / Server with Unix the same as WINDOWS.

The first parameter ("KB" or "kb") is case insensitive.

Two new Error Codes are defined in support of this function:

  • 0412 Invalid Action Code - The first parameter is not recognized.
  • 0413 Window Not On Top - A KB message was sent to a task which is different from the one that currently owns the keyboard.

Note that the following error codes may be related to this function:

  • 0414 Wrong number of arguments passed
  • 0415 Some error that has err message
  • 0416 Not enough elements in dimensioned array
  • 0417 Dimensioned string length is not big enough
  • 0418 Unknown
  • 0419 Error in special char spec

Special Keystroke Values

This facility operates through the operating system, so it does not utilize BR scancodes. If you need to send a special character (which in turn may cause BR to generate its scancodes), you will need to emulate the corresponding keyboard activity. Special characters need to be enclosed in pipes |.

Examples

If you want to send ctrl+c, you must send the following string:

00010 MSG("KB","|CTRL+|c|CTRL-|")

This says that you want depress the "CTRL" key, type "c", and then release "CTRL".


Example:

MSG("KB","|CTRL+|p|CTRL-|")

Will input the CTRL-P character, which causes BR to perform a printscreen operation.

Special Character List

Each char must be enclosed in pipes

ALT+ press ALT - see note below
ALT- release ALT
CTRL+ press CTRL
CTRL- release CTRL
SHIFT+ press SHIFT
SHIFT- release SHIFT
TAB press the tabulation key
RET press the return key
ESC press the escape key
BACK press the backward key
DEL press the delete key
INS press the insert key
HELP press the help key
LEFT send the cursor to the left (left arrow)
RIGHT send the cursor to the right (right arrow)
UP send the cursor up (up arrow)
DOWN send the cursor down (down arrow)
PGUP press the page up key
PGDN press the page down key
HOME press the home key
END press the end key
F1 press the function key F1
F2 press the function key F2
F3 press the function key F3
F4 press the function key F4
F5 press the function key F5
F6 press the function key F6
F7 press the function key F7
F8 press the function key F8
F9 press the function key F9
F14 press the function key F14
F11 press the function key F11
F12 press the function key F12
NUM0 press the 0 on the key pad
NUM1 press the 1 on the key pad
NUM2 press the 2 on the key pad
NUM3 press the 3 on the key pad
NUM4 press the 4 on the key pad
NUM5 press the 5 on the key pad
NUM6 press the 6 on the key pad
NUM7 press the 7 on the key pad
NUM8 press the 8 on the key pad
NUM9 press the 9 on the key pad
NUM* press the * on the key pad
NUM+ press the + on the key pad
NUM- press the - on the key pad
NUM, press the , on the key pad
NUM/ press the / on the key pad

To send the pipe character specify |||.

MSG("sleeptime",seconds) specifies the number of seconds to wait before issuing each string and each control character. Seconds may also be expressed with *up to three decimal digits* The default value is 0.2 seconds.

Please note that the ALT key needs to be depressed and released (ALT+ and ALT-) for every Alt-character specified.

|alt+|m|alt-||alt+|b|alt-| works

|alt+|mb|alt-| fails

|alt+|m|down||alt-| works

This is because keyboard entries don't interpret more than one keystroke as an alt value except when using the numeric keypad. However Windows will honor arrow keys while the alt key is held down.