PostMessage(hwnd,WM_KEYDOWN,(WPARAM)VK_ESCAPE,0);
如果发送CTRL+A怎么发呢
Alt+Enter,Alt+1,那,望各位高手指教
最好详细介绍后两个参数,先谢了,回答后就给分

解决方案 »

  1.   

    WM_SYSKEYDOWN
    The WM_SYSKEYDOWN message is posted to the window with the keyboard focus when the user presses the F10 key (which activates the menu bar) or holds down the ALT key and then presses another key. It also occurs when no window currently has the keyboard focus; in this case, the WM_SYSKEYDOWN message is sent to the active window. The window that receives the message can distinguish between these two contexts by checking the context code in the lParam parameter. A window receives this message through its WindowProc function. LRESULT CALLBACK WindowProc(
      HWND hwnd,       // handle to window
      UINT uMsg,       // WM_SYSKEYDOWN
      WPARAM wParam,   // virtual-key code
      LPARAM lParam    // key data
    );
     应该发送WM_SYSKEYDOWN消息就可以吧。
      

  2.   

    wParam 是虚拟键的代码 如VK_TAB等
    lParam
    lParam 
    Specifies the repeat count, scan code, extended-key flag, context code, previous key-state flag, and transition-state flag, as shown in the following table. Bit Description 
    0–15 Specifies the repeat count for the current message. The value is the number of times the keystroke is autorepeated as a result of the user holding down the key. If the keystroke is held long enough, multiple messages are sent. However, the repeat count is not cumulative. 
    16–23 Specifies the scan code. The value depends on the original equipment manufacturer (OEM). 
    24 Specifies whether the key is an extended key, such as the right-hand ALT and CTRL keys that appear on an enhanced 101- or 102-key keyboard. The value is 1 if it is an extended key; otherwise, it is 0. 
    25–28 Reserved; do not use. 
    29 Specifies the context code. The value is always 0 for a WM_KEYDOWN message. 
    30 Specifies the previous key state. The value is 1 if the key is down before the message is sent, or it is zero if the key is up. 
    31 Specifies the transition state. The value is always zero for a WM_KEYDOWN message. 
      

  3.   

    还有发送CTRL+A怎么发 分别怎么设置wParam 和lParam
      

  4.   

    CTRL+A 应该是先发送CTRL Down消息,再发送A Down消息
    ALT+ENTER 是不是直接发送Enter的WM_SYSKEYDOWN消息?没有试过
      

  5.   

    有没小列子,举例说明CTRL+A和Alt+Enter的消息参数设置行吗?
      

  6.   

    VK_1没定义,怎么回事,用0x31代替编译通过,但执行不正确
      

  7.   

    用SPY++看看你的窗口到底在你按键时收到了什么消息,把那些消息模拟发送一次就可以了。
      

  8.   

    ALT+ENTER 直接发送Enter的WM_SYSKEYDOWN消息 也不行
    郁闷救命啊!
      

  9.   

    完全模拟了spy++抓到的消息,参数也一样,还是不行,啊……
    keydown 00000011(VK_CTRL) 001d001
    keydown 00000031(VK_1)    0002001
      

  10.   

    keydown 00000011(VK_CTRL) 001d0001
    keydown 00000031(VK_1)    00020001PostMessage(hwnd,WM_KEYDOWN,(WPARAM)VK_CONTROL,(LPARAM)0x1d01);
    PostMessage(hwnd,WM_KEYDOWN,(WPARAM)0x31,(LPARAM)0x201);
    //PostMessage(hwnd,WM_KEYUP,(WPARAM)0x31,(LPARAM)0x201);
    //PostMessage(hwnd,WM_KEYUP,(WPARAM)VK_CONTROL,(LPARAM)0x1d01);
    发不发WM_KEYUP一样,且Windows Media Player确实是在WM_KEYDOWN消息后就响应的
      

  11.   

    难道今天要加班肯msdn吗?救命啊,今天周末……
      

  12.   

    向Windows Media Player发送单键消息可以响应如:
    PostMessage(hwnd,WM_KEYDOWN,(WPARAM)VK_SPACE,(LPARAM)0);
    可以控制它的播放和暂停,
    怎样发送组合键哪?如Ctrl+1,Alt+Enter,各位大虾救命,这是我今天的任务,就是控制这该死的微软的Windows Media Player!可恶……
      

  13.   

    to shootingstars(流星) :
       看样子,我的分你是拿定了。
      

  14.   

    呵呵,周末嘛,权当在这里聊天罗,轻松一下,看看你什么时候能搞定。(分数不重要,给不给分都无所谓,自己开心就好)。
    good luck , 周末愉快 ,希望你不用加班加到太晚。
      

  15.   

    更正一下:
    PostMessage(hwnd,WM_KEYDOWN,(WPARAM)VK_CONTROL,(LPARAM)0x1d0001);
    PostMessage(hwnd,WM_KEYDOWN,(WPARAM)0x31,(LPARAM)0x20001);
    error
      

  16.   

    解决啦!
    用spy++跟踪Windows Media Player消息,组合键Ctrl+1被解释成了菜单消息(不知能否这样说)
    发送PostMessage(hwnd,WM_COMMAND,(WPARAM)0xBE4,(LPARAM)0);就搞定啦!
    明天结贴,啊!欢迎继续讨论