keybd_event 和 postmessage 的区别
在msdn的解释里keybd_event是直接驱动键盘驱动程序发出消息给系统,系统再把消息送到当场活动窗口的消息队列; postmessage是直接将消息发送动指定句柄的窗口的消息队列。
问题是:
为什么有些程序能向应keybd_event发出的消息,却不能向应postmessage发出的消息。
举个例子
我用keybd_event往一个游戏发送按键“1”的消息 用spy++捕获消息格式如下:
000406CC P WM_KEYDOWN nVirtKey:'1' cRepeat:1 ScanCode:02 fExtended:0
fAltDown:0 fRepeat:0 fUp:0 [wParam:00000031 lParam: 00020001]
000406CC P WM_KEYUP nVirtKey:'1' cRepeat:1 ScanCode:02 fExtended:0
fAltDown:0 fRepeat:1 fUp:1 [wParam:00000031 lParam: C0020001]
游戏能够同直接按键盘的方式向应
用postmessage往一个游戏发送按键“1”的消息 用spy++捕获的消息格式同keybd_event一样,游戏就是没反应。
请问这是怎么回事?
用keybd_event游戏必须处于前台,没法做其他的事情!
希望大家见仁见智 给出个解决方法。谢谢