writing a key listener in c [closed]

和自甴很熟 提交于 2019-12-25 18:54:38

问题


I want to write my own keylogger using Java. To write the keylogger i would need a hook file that will catch the keyevents by the users. How can i write this hook file so that i am able to get the keys user presses. I am unaware how to write a global key listener in C.


回答1:


What you are trying to do will not be platform independent. As such, I can only give you a hint on how to do it on windows.

In windows, the way to do this is by using the winapi. You can use the SetWindowsHookEx function with the WH_KEYBOARD argument which:

Installs a hook procedure that monitors keystroke messages. For more information, see the KeyboardProc hook procedure.

This way, you will basically tell windows to call your predefined function (sent as argument to SetWindowsHookEx) every time a key is pressed. You can read about specifics on the webpage I gave you.

Since the SetWindowsHookEx function is windows specific, note that you cannot use this on linux or any other os. Also, for a basic program to do what you want, you don't really need Java. You can pretty much do everything in C/C++.



来源:https://stackoverflow.com/questions/10684594/writing-a-key-listener-in-c

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