sendmessage(hwnd,message,wparam,lparam)
message就是你要模拟的键盘消息

解决方案 »

  1.   

    如果 发送WM_KEUP ,WM_KEYDOWN 都会跟一个WM_CHAR消息.
    要如何解决.
      

  2.   

    WM——CHAR可能是WM_KEYUP+WM_KEYDOWN
      

  3.   

    可以使用keybd_event()函数的....
      

  4.   

    不是,如过直接发送消息每一个系统都会给你加一个WM_CHAR
      

  5.   

    keybd_event()有何作用呢,你能详细点吗
      

  6.   

    系统发消息顺序WM_KEYDOWND,WM_CHAR,WM_KEYUP
      

  7.   

    就是模拟键盘的输入。。
        详细的见msdn
       同样有一个函数mouse_event()像鼠标小精灵这些软件,就是使用这些函数编写的。。
      

  8.   

    keybd_event
    The keybd_event function synthesizes a keystroke. The system can use such a synthesized keystroke to generate a WM_KEYUP or WM_KEYDOWN message. The keyboard driver's interrupt handler calls the keybd_event function. Windows NT: This function has been superseded. Use SendInput instead.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. Res
    Although keybd_event passes an OEM-dependent hardware scan code to the system, applications should not use the scan code. The system converts scan codes to virtual-key codes internally and clears the up/down bit in the scan code before passing it to applications. An application can simulate a press of the PRINTSCREEN key in order to obtain a screen snapshot and save it to the clipboard. To do this, call keybd_event with the bVk parameter set to VK_SNAPSHOT, and the bScan parameter set to 0 for a snapshot of the full screen or set bScan to 1 for a snapshot of the active window. Windows CE: Windows CE supports an additional flag for the dwFlags parameter. Use the KEYEVENTF_SILENT flag to simulate a keystroke without making a clicking sound.Windows CE does not support the KEYEVENTF_EXTENDEDKEY flag.QuickInfo
      Windows NT: Requires version 3.1 or later.
      Windows: Requires Windows 95 or later.
      Windows CE: Requires version 1.0 or later.
      Header: Declared in winuser.h.
      Import Library: Use user32.lib.See Also
    Keyboard Input Overview, Keyboard Input Functions, GetAsyncKeyState, GetKeyState, MapVirtualKey, SetKeyboardState 
      

  9.   

    晕!你没有msdn你学习什么vc呀?    keydb_enent(VK_NUMLOCK,0x45,KEYDBEVENT_KEYUP,..);
        具体参数我也忘了,我在网吧里面..    反正大体上是这样了...
      

  10.   

    keybd_event(VK_SHIFT,0,0,0);  // 模拟按下shift
    keybd_event(VK_DIVIDE,0,0,0); // 模拟按下:
    keybd_event(VK_DIVIDE,0,KEYEVENTF_KEYUP,0); // 模拟松开:
    keybd_event(VK_SHIFT,0,KEYEVENTF_KEYUP,0);  // 模拟松开shift给分!
      

  11.   

    可以对WM_KEY_CHAR消息进行响应,自已添加消息映射。
      

  12.   

    你到底要实现什么功能?
        其实,很多时候,不一定使用这么麻烦的函数的。。比方说,sendmessage基本上就可以高定一切基于窗口的输入信息