SendInput 函数详解

//函数
SendInput(
    __in UINT cInputs,                     // number of input in the array
    __in_ecount(cInputs) LPINPUT pInputs,  // array of inputs
    __in int cbSize);                      // sizeof(INPUT)


LPINPUT结构.type
#define INPUT_MOUSE     0
#define INPUT_KEYBOARD  1
#define INPUT_HARDWARE  2

//LPINPUT的结构
typedef struct tagINPUT {
    DWORD   type;

    union
    {
        MOUSEINPUT      mi;
        KEYBDINPUT      ki;
        HARDWAREINPUT   hi;
    };
} INPUT, *PINPUT, FAR* LPINPUT;


//键盘结构
typedef struct tagKEYBDINPUT {
    WORD    wVk;    //0x25
    WORD    wScan;  //MapVirtualKeyExA
    DWORD   dwFlags;  //0/KEYEVENTF_KEYUP
    DWORD   time;    //0
    ULONG_PTR dwExtraInfo;
} KEYBDINPUT, *PKEYBDINPUT, FAR* LPKEYBDINPUT;


//鼠标结构
typedef struct tagMOUSEINPUT {
    LONG    dx;
    LONG    dy;
    DWORD   mouseData;
    DWORD   dwFlags;
    DWORD   time;
    ULONG_PTR dwExtraInfo;
} MOUSEINPUT, *PMOUSEINPUT, FAR* LPMOUSEINPUT;


//硬件结构
typedef struct tagHARDWAREINPUT {
    DWORD   uMsg;
    WORD    wParamL;
    WORD    wParamH;
} HARDWAREINPUT, *PHARDWAREINPUT, FAR* LPHARDWAREINPUT;


汇编中的数据 LPKEYBDINPUT
0012F818  00000001 类型:MyInput[0].type = INPUT_KEYBOARD;
0012F81C  004B0025 高位:MyInput[0].ki.wScan =MapVirtualKeyExA(keyvalue,0,0);
                                低位:MyInput[0].ki.wVk = keyvalue;
0012F820  00000001 标志:MyInput[0].ki.dwFlags =1;
0012F824  0049CF43 时间:MyInput[0].ki.time=timeGetTime();
0012F828  00000000 扩展信息:MyInput[0].ki.dwExtraInfo=0;
0012F82C  00000000
0012F830  00000000

 

 

posted @ 2012-06-01 09:09  未来,为我而来!  阅读(2991)  评论(0编辑  收藏  举报