第一个答对的有分

解决方案 »

  1.   

    mfc中直接调用OnKeyDown();
    SDK中PostMessage(hwnd, WM_CHAR……)什么的
    乱猜的,未验证
      

  2.   

    不是函数,是发送一条WM_KEYDOWN消息
    SendMessage
      

  3.   

    这里是msdn上的解释The SendInput function synthesizes keystrokes, mouse motions, and button clicks.UINT SendInput(
      UINT nInputs,     // count of input events
      LPINPUT pInputs,  // array of input events
      int cbSize        // size of structure
    );
    Parameters
    nInputs 
    [in] Specifies the number of structures in the pInputs array. 
    pInputs 
    [in] Pointer to an array of INPUT structures. Each structure represents an event to be inserted into the keyboard or mouse input stream. 
    cbSize 
    [in] Specifies the size, in bytes, of an INPUT structure. If cbSize is not the size of an INPUT structure, the function will fail. 
    Return Values
    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. Res
    The SendInput function inserts the events in the INPUT structures serially into the keyboard or mouse input stream. These events aren't 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.
      

  4.   

    用keybd_event()函数VOID keybd_event(
      BYTE bVk,           // virtual-key code
      BYTE bScan,         // hardware scan code
      DWORD dwFlags,      // flags specifying various function options
      DWORD dwExtraInfo   // additional data associated with keystroke
    );
     
    Parameters
    bVk 
    Specifies a virtual-key code. The code must be a value in the range 1 to 254. 
    bScan 
    Specifies a hardware scan code for the key. 
    dwFlags 
    A set of flag bits that specify various aspects of function operation. An application can use any combination of the following predefined constant values to set the flags. Value Meaning 
    KEYEVENTF_EXTENDEDKEY If specified, the scan code was preceded by a prefix byte having the value 0xE0 (224). 
    KEYEVENTF_KEYUP If specified, the key is being released. If not specified, the key is being depressed. 
    dwExtraInfo 
    Specifies an additional 32-bit value associated with the key stroke. 
    Return Values
    This function has no return value.