获取所有按下的按键

发布于 2024-10-06 14:47:50 字数 79 浏览 0 评论 0原文

那么是否有可能在任何应用程序的任何地方按下所有按键?或多或少像一个键盘记录器。我想知道这在 C++ 或 C# 中是否可行。

问候

So is there possible to intersect all keys pressed everywhere, where everywhere is at any application? More or so like a keylogger. I was wondering if that is possible in C++ or C#.

Regards

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

尝蛊 2024-10-13 14:47:50

您正在寻找的是键盘挂钩。使用一些 P/Invoke 可以实现这一点。请参阅此处的示例:

http://www.codeproject.com/KB/cs/CSLLKeyboardHook.aspx

What you're looking for is a Keyboard Hook. This is possible using some P/Invoke. See sample here:

http://www.codeproject.com/KB/cs/CSLLKeyboardHook.aspx

风尘浪孓 2024-10-13 14:47:50

如果您想使用 winapi thaen 函数,您正在寻找带有 WH_KEYBOARD 标志的 SetWindowsHookEx 。如果你想获得真正的所有kes,你可以使用low-lewel标志代替WH_KEYBOARD_LL,但这不会翻译击键,所以它更难使用。

我从未使用过这个标志,但我知道某些标志需要在单独的模块(例如 dll)中注册钩子函数,因为它们将在实际接收键盘输入的应用程序上下文中加载和执行。如果是这样,您还必须考虑一种将收集的数据返回到应用程序的机制,因为全局变量将不起作用。

If you want to use winapi thaen function you are looking for is SetWindowsHookEx with flag WH_KEYBOARD. If you want to get really all kes you might use low-lewel flag instead WH_KEYBOARD_LL, but this will not translate keystrokes, so it's more difficult to work with.

I never used this flag, but i know that some flags need registered hook function to be in separate module (eg. dll) as they will be loaded and executed executed in context of application that actually recieves keyboard input. If it is so you must also think of a mechanism of returning colected data back to your application, cause global variables will not work.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文