Compartir a través de


IVMKeyboard interface

The IVMKeyboard interface controls the keyboard device within a virtual machine. The IVMKeyboard for a virtual machine can be retrieved using the IVMVirtualMachine::Keyboard property.

When to use

Keys can be typed into the virtual machine in several ways. To type a normal ASCII sequence of characters, use the TypeAsciiText method. If greater flexibility is required, IVMKeyboard has several methods that are designed to be used with the key codes in the following list. The TypeKeySequence method can accept a comma-delimited string of key codes, which will be pressed and released, in order, within the virtual machine. In addition to these key codes, the keywords UP and DOWN can be used to force a key to only be pressed, or only be released. The UP and DOWN keywords only apply to the key code directly following the keyword. The following examples illustrate the use of TypeAsciiText and TypeKeySequence:

keyboard.TypeKeySequence("DOWN, Key_LeftShift, Key_M, UP, Key_LeftShift, Key_I, Key_C, Key_R, Key_O, Key_S, Key_O, Key_F, Key_T, Key_Space");
    keyboard.TypeAsciiText("Virtual Server");

The previous code will type "Microsoft Virtual Server" into the virtual machine. Also, to press or release a single key, the PressKey, ReleaseKey, and PressAndReleaseKey methods may be used with the following key codes.

To avoid multiple scripts, applications, or users from simultaneously attempting to access the same keyboard device, set the HasExclusiveAccess property to TRUE. If exclusive access is acquired by one process, any attempts by other processes to send input to the keyboard device will be ignored until exclusive access has been released.

A list of valid key identifier codes and modifiers can be found in the Key Identifiers Reference topic.

Members

The IVMKeyboard interface inherits from the IDispatch interface. IVMKeyboard also has these types of members:

Methods

The IVMKeyboard interface has these methods.

Method Description
IsPressed Retrieves the current state (pressed or released) of the specified key within the virtual machine.
PressAndReleaseKey Simulates the given key being pressed down and then released inside the virtual machine.
PressKey Simulates the given key being pressed down inside the virtual machine.
ReleaseKey Simulates the given key being released inside the virtual machine.
TypeAsciiText Simulates the given series of ASCII keys being typed (pressed and then released) in the virtual machine.
TypeKeySequence Simulates the given series of keys being typed (pressed and then released) inside the virtual machine.

Properties

The IVMKeyboard interface has these properties.

Property Access type Description
HasExclusiveAccess
Read/write
Indicates whether this IVMKeyboard object has exclusive control over the virtual machine's keyboard device.

Requirements

Product
Microsoft Virtual Server 2005 onWindows Server 2003
Download
Microsoft Virtual Server 2005 R2 SP1 Update onWindows Server 2008orWindows Server 2003
Header
VsComInterfaces.h

See also

IDispatch