INPUT

The INPUT structure is used by SendInput to synthesize keystrokes, mouse motions, and button clicks.

typedef struct tagINPUT {
    DWORD   type;
    union
    {
        MOUSEINPUT      mi;
        KEYBDINPUT      ki;
        HARDWAREINPUT   hi;
    };
} INPUT, *PINPUT, FAR* LPINPUT;
 

Members

type
Specifies the type of the input event. It can be one of the following values.
Value Meaning
INPUT_MOUSE The event is a mouse event. Use the mi structure of the union.
INPUT_KEYBOARD The event is a keyboard event. Use the ki structure of the union.
INPUT_HARDWARE Windows 95: The event is from input hardware other than a keyboard or mouse. Use the hi structure of the union.

mi
Specifies a mouse event.
typedef struct tagMOUSEINPUT {
    LONG    dx;
    LONG    dy;
    DWORD   mouseData;
    DWORD   dwFlags;
    DWORD   time;
    DWORD   dwExtraInfo;
} MOUSEINPUT, *PMOUSEINPUT, FAR* LPMOUSEINPUT;
 
dx, dy
Specifies the mouse's absolute position or its amount of motion since the last mouse event was generated, depending on the setting of MOUSEEVENTF_ABSOLUTE in dwFlags. Absolute data is given as the mouse's actual x- and y-coordinates; relative data is given as the number of pixels moved.
mouseData
If dwFlags contains MOUSEEVENTF_WHEEL, then mouseData specifies the amount of wheel movement. A positive value indicates that the wheel was rotated forward, away from the user; a negative value indicates that the wheel was rotated backward, toward the user. One wheel click is defined as WHEEL_DELTA, which is 120.

If dwFlags does not contain MOUSEEVENTF_WHEEL, then mouseData should be zero.

dwFlags
A set of bit flags that specify various aspects of mouse motion and button clicks. The bits in this member can be any reasonable combination of the following values.
Value Meaning
MOUSEEVENTF_ABSOLUTE Specifies that the dx and dy members contain normalized absolute coordinates. If the flag is not set, the dx and dy members contain relative data: the change in position since the last reported position. This flag can be set, or not set, regardless of what kind of mouse or other pointing device, if any, is connected to the system. For further information about relative mouse motion, see the following Remarks section.
MOUSEEVENTF_MOVE Specifies that movement occurred.
MOUSEEVENTF_LEFTDOWN Specifies that the left button was pressed.
MOUSEEVENTF_LEFTUP Specifies that the left button was released.
MOUSEEVENTF_RIGHTDOWN Specifies that the right button was pressed.
MOUSEEVENTF_RIGHTUP Specifies that the right button was released.
MOUSEEVENTF_MIDDLEDOWN Specifies that the middle button was pressed.
MOUSEEVENTF_MIDDLEUP Specifies that the middle button was released.
MOUSEEVENTF_WHEEL Windows NT: Specifies that the wheel was moved, if the mouse has a wheel. The amount of movement is specified in mouseData.

The bit flags that specify mouse button status are set to indicate changes in status, not ongoing conditions. For example, if the left mouse button is pressed and held down, MOUSEEVENTF_LEFTDOWN is set when the left button is first pressed, but not for subsequent motions. Similarly, MOUSEEVENTF_LEFTUP is set only when the button is first released.

time
Time stamp for the event.
dwExtraInfo
Specifies an additional 32-bit value associated with the mouse event. An application calls GetMessageExtraInfo to obtain this extra information.
ki
Specifies a keyboard event.
typedef struct tagKEYBDINPUT {
    WORD    wVk;
    WORD    wScan;
    DWORD   dwFlags;
    DWORD   time;
    DWORD   dwExtraInfo;
} KEYBDINPUT, *PKEYBDINPUT, FAR* LPKEYBDINPUT;
 
wVk
Specifies a virtual-key code. The code must be a value in the range 1 to 254.
wScan
Specifies a hardware scan code for the key.
dwFlags
A set of bit flags that specify various aspects of a keystroke. The bits in this member can be any combination of the following predefined constant values.
Value Meaning
KEYEVENTF_EXTENDEDKEY If specified, the scan code was preceded by a prefix byte that has the value 0xE0 (224).
KEYEVENTF_KEYUP If specified, the key is being released. If not specified, the key is being pressed.

time
Time stamp for the event.
dwExtraInfo
Specifies an additional 32-bit value associated with the keystroke. An application calls GetMessageExtraInfo to obtain this extra information.
hi
Windows 95: Specifies an event from input hardware other than a keyboard or mouse.
typedef struct tagHARDWAREINPUT {
    DWORD   uMsg;
    WORD    wParamL;
    WORD    wParamH;
    DWORD   dwExtraInfo;
} HARDWAREINPUT, *PHARDWAREINPUT, FAR* LPHARDWAREINPUT;
 
uMsg
The message generated by the input hardware.
wParamL
Parameter for uMsg.
wParamH
Parameter for uMsg.
dwExtraInfo
Specifies an additional 32-bit value associated with the event. An application calls GetMessageExtraInfo to obtain this extra information.

Remarks

If the mouse has moved, indicated by MOUSEEVENTF_MOVE being set, dx and dy specify information about that motion. The information is given as absolute or relative integer values.

If MOUSEEVENTF_ABSOLUTE value is specified, dx and dy contain normalized absolute coordinates between 0 and 65,535. The event procedure maps these coordinates onto the display surface. Coordinate (0,0) maps onto the upper-left corner of the display surface; coordinate (65535,65535) maps onto the lower-right corner.

If the MOUSEEVENTF_ABSOLUTE value is not specified, dx and dy specify motions relative to the previous mouse event (the last reported position). Positive values mean the mouse moved right (or down); negative values mean the mouse moved left (or up).

Relative mouse motion is subject to the effects of the mouse speed and the two mouse threshold values. A user sets these three values with the Pointer Speed slider of the Control Panel's Mouse Properties sheet. An application obtains and sets these values with the SystemParametersInfo function.

The operating system applies two tests to the specified relative mouse motion. If the specified distance along either the x or y axis is greater than the first mouse threshold value, and the mouse speed is not zero, the operating system doubles the distance. If the specified distance along either the x or y axis is greater than the second mouse threshold value, and the mouse speed is equal to two, the operating system doubles the distance that resulted from applying the first threshold test. It is thus possible for the operating system to multiply specified relative mouse motion along the x or y axis by up to four times.

QuickInfo

  Windows NT: Requires version 4.0 SP3 or later.
  Windows: Requires Windows 98 or later.
  Windows CE: Unsupported.
  Header: Declared in winuser.h.

See Also

Keyboard Input Overview, Keyboard Input Structures, GetMessageExtraInfo, SendInput, SystemParametersInfo