Capture All Keyboard Input

荒凉一梦 提交于 2021-02-07 17:30:38

问题


First off, I know this could be used for a keylogger. I'm not going for that, I'm looking to make an application that listens for custom key combinations just to automate a few really annoying tasks.

Is there some way to capture all input from the keyboard?


回答1:


You appear to be looking for RegisterHotKey().

I don't think you want to hook all keyboard input. You simply want an app with a hidden window listening for WM_HOTKEY. I don't think you even need to write it yourself. There are a lots of utilities that will do it for you and let you associate system-wide hot keys with actions of your specification, e.g. AutoHotKey.




回答2:


to capture keyboard input even when your application is not focused, you need to use windows hook, WH_KEYBOARD one. It should be implemented as a DLL to be injected into all processes. Example here



来源:https://stackoverflow.com/questions/6630623/capture-all-keyboard-input

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