c++ win32 Simulate Keypress with DirectInput

陌路散爱 提交于 2019-12-04 11:27:39

SendInput

SendInput lets you simulate key presses. You have a choice of identifying keys using either virtual key codes or scan codes (see KEYBDINPUT.dwFlags). Apparently, DirectInput ignores virtual key codes but does process scan codes.

In short, use SendInput with scan codes and DirectInput will respond.

Interception

The Interception toolkit simulates key presses with a kernel mode driver and some user mode helper functions.

There are some security worries. Since it's a closed-source kernel mode driver you need to completely trust the author. Even if the author is entirely trustworthy the driver allows input to be monitored, as well as created, so it opens a big security hole: any unprivileged software could use it to sniff, for example, elevation passwords. It can also block keyboard input including CTRL+ALT+DEL.

Comments on the github page suggest it doesn't yet work in Windows 8.

Use it at your own risk.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!