WriteConsoleInput

  BOOL WriteConsoleInput(hConsoleInput, pirBuffer, cInRecords, lpcWritten)    
  HANDLE hConsoleInput; /* identifies console input buffer */
  PINPUT_RECORD pirBuffer; /* address of the buffer for write data */
  DWORD cInRecords; /* number of records to write */
  LPDWORD lpcWritten; /* returns number of records written */

The WriteConsoleInput function writes data directly to the console input buffer.

Parameters

hConsoleInput

Identifies the console input buffer to write to. The handle must have been created with GENERIC_WRITE access.

pirBuffer

Points to an INPUT_RECORD buffer containing data to be written to the console input buffer data.

The INPUT_RECORD data structure has the following format:

typedef struct _INPUT_RECORD { /* ir */

WORD EventType;

union {

KEY_EVENT_RECORD KeyEvent;

MOUSE_EVENT_RECORD MouseEvent;

WINDOW_BUFFER_SIZE_RECORD WindowBufferSizeEvent;

MENU_EVENT_RECORD MenuEvent;

FOCUS_EVENT_RECORD FocusEvent;

} Event;

} INPUT_RECORD;

cInRecords

Specifies the length of pirBuffer (in input records).

lpcWritten

Points to a variable to receive the number of input records written.

Return Value

The return value is TRUE if the function was successful, or FALSE if an error occurred. Use the GetLastError function to obtain extended error information.

Comments

The function places input records into the input buffer behind any pending events in the buffer.

The input buffer grows dynamically, if necessary, to hold as many events as are written.

The WriteConsoleInput function may be used as either a wide-character function (where text arguments must use Unicode) or an ANSI function (where text arguments must use characters from the Windows 3.x character set installed).

See Also

ReadConsoleInput, WriteConsoleOutput, WriteConsoleOutputCharacter, WriteConsoleOutputAttribute