用sendkeyevent()是没有用的呵呵呵呵.
我估计这个函数就是用来Qt程序内部传递keyevent.如果你用影响到程序外面的话.
window平台下就应该
#include
然后
使用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
);
你是做了很多按钮,然后响应按钮按下的消息吗?如果是这样的话,就在按钮按下的消息函数里添加如下的代码就行了(反正就是添加到你需要模拟按键的那个地方):
keybd_event(VK_H, 0, 0, 0); // 模拟按下H键
要模拟其他键只需要把第一个参数改成相应的虚键值就行了,所有的虚键值表示如下:
KEY_EVENT_BASE
The base identifier for all UIKeyEvent events.
KEY_PRESSED
The key pressed event type.
KEY_RELEASED
The key released event type.
KEY_TYPED
The key typed event type, which is generated by a combination of a key press followed by a key release.
VK_0
VK_0 through VK_9 are the same as ASCII "0" through "9" (0x30 - 0x39).
VK_1
A virtual key code for the ASCII "1" key.
VK_2
A virtual key code for the ASCII "2" key.
VK_3
A virtual key code for the ASCII "3" key.
VK_4
A virtual key code for the ASCII "4" key.
VK_5
A virtual key code for the ASCII "5" key.
VK_6
A virtual key code for the ASCII "6" key.
VK_7
A virtual key code for the ASCII "7" key.
VK_8
A virtual key code for the ASCII "8" key.
VK_9
A virtual key code for the ASCII "9" key.
VK_A
VK_A through VK_Z are the same as ASCII "A" through "Z" (0x41 - 0x5A).
VK_ACCEPT
For Asian keyboards.
VK_ADD
A virtual key code for the numeric keypad PLUS SIGN (+) key.
VK_ALT
A virtual key code for the ALT key.
VK_B
表示下面还有很多,自己去查下.
如果你在linux下方法类似但是忘了.............
呵呵呵呵呵