如何使用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 那么,谁能告诉我如何模拟,例如,在游戏中按下左箭头键?
发布于 2013-03-03 21:46:35
SendInput
SendInput允许您模拟按键操作。您可以选择使用虚拟键码或扫描码来识别按键(请参阅KEYBDINPUT.dwFlags)。显然,DirectInput忽略了虚拟键码,但确实会处理扫描码。
简而言之,使用带有扫描码的SendInput,DirectInput将会响应。
拦截
Interception工具包使用内核模式驱动程序和一些用户模式帮助器函数模拟按键。
这里有一些安全方面的担忧。因为它是一个封闭源代码的内核模式驱动程序,所以你需要完全信任作者。即使作者是完全值得信任的,驱动程序也允许监控和创建输入,所以它打开了一个很大的安全漏洞:任何没有特权的软件都可以使用它来嗅探,例如,提升密码。它还可以阻止键盘输入,包括CTRL+ALT+DEL。
the github page上的评论表明,它还不能在Windows8上运行。
使用它的风险自负。
https://stackoverflow.com/questions/7320424
复制相似问题