次の方法で共有


IIMCallback3::SendVirtualKey (Compact 2013)

3/28/2014

This method simulates a keystroke or a virtual key when the input method calls it. SendVirtualKey sends the key event to the active window.

Syntax

HRESULT SendVirtualKey( 
  BYTE bVk, 
  DWORD dwFlags
);

Parameters

  • bVk
    Byte containing the virtual key code of the key to simulate.
  • dwFlags
    State of the key. The following table shows the possible values. These values can be used in combination.

    Value

    Description

    KEYEVENTF_KEYUP

    If this flag is set, a call to SendVirtualKey generates a WM_KEYUP message. If this flag is not set, a call to SendVirtualKey generates a WM_KEYDOWN message.

    KEYEVENTF_SILENT

    If this flag is set, the key the user pressed to activate SendVirtualKey does not make a keyboard click sound, even if clicks are enabled on the device.

Return Value

The following table shows the possible return values.

Value

Description

S_OK

Success.

E_INVALIDARG

Invalid method parameter.

E_FAIL

Other failure. To get more information, call GetLastError.

Remarks

This method modifies the global key state for the virtual key sent in bVk. For example, an input method can use this method to send SHIFT, CTRL, and ALT key up and key down events. An application retrieves these events when it calls the GetKeyState function.

You can use this method to send virtual key events that do not have associated characters. Do not use it to send VK_* messages that cause a WM_CHAR message to be sent in the TranslateMessage function.

If this method sends a character-producing virtual key, the global key state modifies the key. For example, an application can use this method to send a VK_5 message to the current application. If the SHIFT global key is down, the application receives the % character message, depending on the computer's keyboard driver.

You can also send character messages and strings using the IIMCallback3::SendCharEvents and IIMCallback3::SendString methods. Call the IIMCallback3::SendCharEvents and IIMCallback3::SendString methods instead of the keybd_event function when programming an input method.

Requirements

Header

sip.h

Library

uuid.lib

sysgen

SYSGEN_SOFTKB

See Also

Reference

IIMCallback3
WM_CHAR
WM_KEYDOWN
WM_KEYUP
keybd_event (deprecated)
TranslateMessage
IIMCallback3::GetInputContext
IIMCallback3::SendAlternatives2
IIMCallback3::SendCharEvents
IIMCallback3::SendString
IIMCallback3::SetImInfo