如何“冻结"使用RAW INPUT(块)键? [英] How to "freeze" (block) a key using RAW INPUT??

查看:64
本文介绍了如何“冻结"使用RAW INPUT(块)键?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

From the MSDN documentation:

...如果挂钩过程超时,系统会将消息传递到下一个挂钩.但是,在Windows 7和更高版本上, .应用程序无法知道是否已删除该挂钩.

... If the hook procedure times out, the system passes the message to the next hook. However, on Windows 7 and later, the hook is silently removed without being called. There is no way for the application to know whether the hook is removed.

...在大多数情况下,应用程序需要使用低级钩子,因此

... In most cases where the application needs to use low level hooks, it should monitor RAW INPUT instead. This is because raw input can asynchronously monitor mouse and keyboard messages that are targeted for other threads more effectively than low level hooks can


这是真实的!使用Windows7时,使用低级挂钩有很多问题,而使用RAW INPUT则没有任何问题.


This is true! With Windows7 I have lot of problems using low level hook, and NO problems using RAW INPUT.

但是有一个问题 ...使用基于

But there is a problem... with a code based on  SetWindowsHookEx and CallNextHookEx is easy to "freeze" one or more keys with a something like:

If e.Handled Then
    Return New IntPtr(1)
End If


但是,如何使用RAW INPUT冻结(阻止)某些键?
使用RAW INPUT,我不会继承System.Windows.Forms.KeyEventArgs,因此我没有将e.Handled = True放在哪里的KeyPress事件


But using RAW INPUT how can I freeze (block) some key??
With RAW INPUT I don't Inherits System.Windows.Forms.KeyEventArgs, so I have not KeyPress event where to put e.Handled = True

推荐答案

埃齐奥,

This article and the enclosed code demonstrate how to handle raw input in order to process keystrokes and identify which device they come from (this code is in C# but with every converter it can be converted to VB), you can refer that if it helps.

还有在这种情况下是类似的问题,请参考:

http://stackoverflow.com/questions/13076060/low-level-keyboard-hook-来自rawinput的击键

希望它是对您有帮助.

最好的问候,

张娜达


这篇关于如何“冻结"使用RAW INPUT(块)键?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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