转自不用winio,直接达到驱动级模拟键盘效果的keybd_event函数用法
键盘模拟技术是在编写游戏外挂时经常使用的技术。但是由于很多游戏采用了directinput的方式,使得发送的一般键盘消息无法被程序收到。这时候需要使用驱动级的键盘模拟技术,直接发送键盘的硬件扫描码,达到模拟键盘的目的。
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.
-