Simulating Input

[This is preliminary documentation and subject to change.]

Applications can use Active Accessibility's SendInput function to simulate an uninterrupted series of user input events. SendInput provides the same functionality as the mouse_event, keyboard_event, and hardware_event Win32 functions. The SendInput function accepts three parameters. The first parameter, cInputs, indicates the number of input events that will be simulated. The second parameter, rgInputs, is the base address of an array of INPUT structures, each describing a type of input event and additional information about that event. The last parameter, cbSize, accepts the size of the INPUT structure, in bytes.

SendInput works by injecting a series of simulated input events into a device's input stream. The effect is similar to calling the keybd_event or mouse_event Win32 functions repeatedly, except that the application ensures that no other input events intermingle with the simulated events. When the call completes, the return value indicates the number of input events successfully played to the system. If this value is zero, then input was blocked.

The SendInput function does not reset the keyboard's current state. Therefore, if the user has any keys pressed when you call this function, they might interfere with the events that this function generates. If you are concerned about possible interference, check the keyboard's state with the GetAsyncKeyState Win32 function and correct as necessary.