Gab*_*ros 4 c c++ winapi directinput
如何使用DirectInput模拟按键?我目前有初始化(但我不确定它是否好):
#include <dinput.h>
#pragma comment (lib, "dinput8.lib")
#pragma comment (lib, "dxguid.lib")
LPDIRECTINPUT8 din; // the pointer to our DirectInput interface
LPDIRECTINPUTDEVICE8 dinkeyboard; // the pointer to the keyboard device
BYTE keystate[256]; // the storage for the key-information
void initDInput(HINSTANCE hInstance, HWND hWnd); // sets up and initializes DirectInput
void detect_input(void); // gets the current input state
void cleanDInput(void); // closes DirectInput and releases memory
Run Code Online (Sandbox Code Playgroud)
那么有人可以告诉我如何模拟例如在游戏中按下左箭头键吗?
SendInput
SendInput允许您模拟按键.您可以选择使用虚拟键代码或扫描代码识别密钥(请参阅KEYBDINPUT.dwFlags).显然,DirectInput忽略虚拟键代码但会处理扫描代码.
简而言之,使用带扫描码的SendInput和DirectInput将响应.
截击
在拦截工具包模拟与内核模式驱动程序以及一些用户模式辅助功能按键.
有一些安全问题.由于它是一个闭源内核模式驱动程序,因此您需要完全信任作者.即使作者完全值得信赖,驱动程序也允许监视和创建输入,因此它打开了一个很大的安全漏洞:任何无特权的软件都可以使用它来嗅探,例如,提升密码.它还可以阻止键盘输入,包括CTRL + ALT + DEL.
对github页面的评论表明它在Windows 8中尚未运行.
需要您自担风险使用它.
| 归档时间: |
|
| 查看次数: |
6592 次 |
| 最近记录: |