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

问题描述

从MSDN文档中:

From the MSDN documentation:

...在大多数情况下,应用程序需要使用低级钩子,因此应该改为监视RAW INPUT .这是因为原始输入 与低级挂钩相比,可以更有效地异步监视针对其他线程的鼠标和键盘消息

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

但是有一个问题 ...使用基于 SetWindowsHookEx CallNextHookEx 很容易冻结",一个或多个键,类似于:

But there is a problem... with a code based on  SetWindowsHookExand 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

推荐答案

和随附的代码演示了如何处理原始输入以处理击键 并确定它们来自哪个设备(此代码在C#中,但是每个转换器都可以将其转换为VB),如果有帮助,可以参考.

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(块)键?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-29 15:41