Programming with Reflection

image\rwnprg32.gif SetKeyMap method


Syntax object.SetKeyMap Modifiers, Key, CommandType, Commands, [CommandArguments]



Maps a PC keystroke to an action. The action is determined by the CommandType and Commands arguments.

For example, this command maps the F4 key to transmit the string "quit":

.SetKeyMap rcNormalKey, "F4", rcTransmitString, "quit"

This command maps the Alt+Z keystroke combination to run a macro called "Test," and passes a value of "x" to the MacroData property:

.SetKeyMap rcAltKey, "z", rcVBMacro, "test", "x"

This command maps Alt+F5 to two Help menu commands, first the display of the Reflection About box, and then opening the Help contents:

SetKeyMap rcAltKey, "F5", rcBuiltInFunction, "HelpAboutReflection HelpContents"


Modifiers Argument Type: Enumeration
A keystroke consists of a primary key and may also include one or more modifier keys—Alt, Ctrl, and Shift. If you are mapping to an unmodified keystroke, use rcNormalKey for this argument. The possible modifier keys are:


 No modifier.


 The Alt key.


 The Control key.


 The Shift key.

 To specify multiple modifier keys, use the addition operator (+). For example: rcAltKey + rcCtrlKey.

Key Argument Type: String
A string representing a PC key, such as "K," "F1," or "NumLock." Click here to see a list of keys.

CommandType Argument Type: Enumeration
Specifies what sort of command to attach to the keystroke. The possible values are:


 Maps the keystroke to one or more built-in functions.


 Maps the keystroke to a string that is transmitted to the host when the keystroke is pressed. The string is assumed to be in the Windows character set, and is translated into the appropriate host character set as it is transmitted.


 Resets the keystroke to its default mapping. If you use this option, the final Commands argument must be an empty string. For example:

Session.SetKeyMap rcNormalKey, "F1", rcDefaultMap, ""


 Maps the keystroke to a single Visual Basic statement. This statement can include Visual Basic functions and statements and/or Reflection methods and propertiers. Use doubled quotation marks for string values within literal strings, for example:

        .SetKeyMap rcAltKey, "F1", rcVBCommand, "MsgBox ""Hello"""

 Note: This value is equivalent to rcRBCommand, which was used in earlier versions of Reflection.


 Maps the keystroke to a Reflection macro. Use the Commands argument to specify the macro's name. You can pass additional information to the MacroData property using CommandArguments. Note: If the macro is not present in the current settings file or a referenced file, you will see an error when you press the specified keystroke combination.


 Maps the keystroke to a Reflection Basic script. Use the Commands argument to specify the script's path and file name. You can pass arguments to the script using CommandArguments.


 Maps the keystroke to an RCL command or script.

Commands Argument Type: String
Specifies the action to perform when the key is pressed. Depending on the value of CommandType this can be a built-in function, a string to transmit, a Visual Basic statement, a Reflection macro, a Reflection Basic script, an RCL command, or an RCL script.

CommandArguments Argument Type: String
This argument is valid when CommandType is rcVBMacro or rcRBScript. Use it to specify additional information to be passed to the macro or script.


image\jump.gif Keyword Index

image\popup.gif Related Topics

image\popup.gif Reflection products that use this command