写在C键侦听器 [英] writing a key listener in c

查看:142
本文介绍了写在C键侦听器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想用Java写我自己的键盘记录器。写的键盘记录我需要一个钩子文件将由用户捕捉的KeyEvent。我怎样才能让我能够拿到钥匙用户presses写这个钩子文件。我不知道如何用C来写一个全球性的关键监听器。

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.

推荐答案

什么你正在尝试做的不会是独立的平台。因此,我只能给你如何做到这一点在Windows上的提示。

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.

在窗口,要做到这一点的方式是使用WINAPI。您可以使用 SetWindowsHookEx函数 WH_KEYBOARD 参数函数:

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

安装监视击键消息一个钩子程序。欲了解更多信息,请参阅KeyboardProc钩子程序。

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

这样的话,你会基本上告诉Windows打电话给你的predefined功能(发送为参数来调用SetWindowsHookEx)每次关键是pressed时间。你可以阅读有关我给你的网页的具体细节。

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.

由于SetWindowsHookEx函数是windows具体请注意,你不能在Linux或任何其他操作系统使用。另外,对于一个基本的程序做你想要什么,你并不真正需要的Java。您可以pretty很多做C / C ++的一切。

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++.

这篇关于写在C键侦听器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆