Export (0) Print
Expand All

SendInput function

Synthesizes keystrokes, mouse motions, and button clicks.

Syntax


UINT WINAPI SendInput(
  _In_  UINT nInputs,
  _In_  LPINPUT pInputs,
  _In_  int cbSize
);

Parameters

nInputs [in]

Type: UINT

The number of structures in the pInputs array.

pInputs [in]

Type: LPINPUT

An array of INPUT structures. Each structure represents an event to be inserted into the keyboard or mouse input stream.

cbSize [in]

Type: int

The size, in bytes, of an INPUT structure. If cbSize is not the size of an INPUT structure, the function fails.

Return value

Type: UINT

The function returns the number of events that it successfully inserted into the keyboard or mouse input stream. If the function returns zero, the input was already blocked by another thread. To get extended error information, call GetLastError.

This function fails when it is blocked by UIPI. Note that neither GetLastError nor the return value will indicate the failure was caused by UIPI blocking.

Remarks

This function is subject to UIPI. Applications are permitted to inject input only into applications that are at an equal or lesser integrity level.

The SendInput function inserts the events in the INPUT structures serially into the keyboard or mouse input stream. These events are not interspersed with other keyboard or mouse input events inserted either by the user (with the keyboard or mouse) or by calls to keybd_event, mouse_event, or other calls to SendInput.

This function does not reset the keyboard's current state. Any keys that are already pressed when the function is called might interfere with the events that this function generates. To avoid this problem, check the keyboard's state with the GetAsyncKeyState function and correct as necessary.

Because the touch keyboard uses the surrogate macros defined in winnls.h to send input to the system, a listener on the keyboard event hook must decode input originating from the touch keyboard. For more information, see Surrogates and Supplementary Characters.

An accessibility application can use SendInput to inject keystrokes corresponding to application launch shortcut keys that are handled by the shell. This functionality is not guaranteed to work for other types of applications.

Requirements

Minimum supported client

Windows 2000 Professional [desktop apps only]

Minimum supported server

Windows 2000 Server [desktop apps only]

Header

Winuser.h (include Windows.h)

Library

User32.lib

DLL

User32.dll

See also

Reference
INPUT
GetAsyncKeyState
keybd_event
mouse_event
Conceptual
Keyboard Input
Surrogates and Supplementary Characters

 

 

Community Additions

ADD
Show:
© 2014 Microsoft