深度postmessage

 

关于向Windows窗口发送Alt组合键的问题,这个真是经典问题啊,在网上找了一下,问的人N多,方法差不多,

但就是没有很好解决问题。

之前找到一个能正确发送的code:(Alt+A)

PostMessage(hWnd,WM_SYSKEYDOWN,VK_MENU,0);

PostMessage(hWnd,WM_SYSKEYDOWN,0x41,0);

Sleep(50);

PostMessage(hWnd,WM_SYSKEYUP,0x41,0);

PostMessage(hWnd,WM_SYSKEYUP,VK_MENU,0);

有人解释说,按下组合键的时候系统是发两条消息的

但是看到Win32 SDK,感觉上就发一次就可以了……

偶然间又看到最后一个参数的说明,有所发现!先看WM_SYSKEYDOWN的help

The WM_SYSKEYDOWN message is posted to the window with the keyboard focus when the user 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 lKeyD
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值