keybd_event中的bScan参数值0x45是什么意思? [英] What is the meaning of the bScan parameter value 0x45 in keybd_event?

查看:273
本文介绍了keybd_event中的bScan参数值0x45是什么意思?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用 .microsoft.com/en-us/library/windows/desktop/ms646304"rel =" nofollow> keybd_event ,bScan参数的值为0x45.

Many examples of using keybd_event, have the value 0x45 for the bScan parameter.

那个0x45值是什么意思?

What is the meaning of that 0x45 value?

我的印象是 0x45是键盘扫描码,但是由于它用于各种键,我不太确定.

I was under the impression 0x45 was a keyboard scancode, but since it is used for a various number of keys, I'm not so sure about that any more.

我的目标是从.NET P/Invoke或Delphi中使用keybd_event,并使类型更具限制性(例如使用枚举或标记的枚举),这样我的代码将变得更易于维护.

My goal is to use keybd_event either from .NET P/Invoke, or from Delp and make the types more restrictive (using for instance enums or flagged enums) so my code becomes easier to maintain.

推荐答案

这确实是一个扫描代码,对于许多键盘来说,它是NumLock键的扫描代码.

It is indeed a scan code and for many keyboards it is the scan code for the NumLock key.

keybd_event文档附带的示例代码是如何切换NumLock状态的示例.因此,自然将0x45用作扫描代码.我的猜测是,您发现的许多其他示例只是从keybd_event MSDN示例中盲目复制了该值.由于应用程序通常会忽略扫描代码并做出响应对于虚拟键码,通常将扫描码传递给什么值都没有关系.

The example code attached to the documentation of keybd_event is an example of how to toggle the NumLock state. And so naturally 0x45 is used as the scan code. My guess is that lots of the other examples that you found simply copied blindly that value from the keybd_event MSDN example. Since applications typically ignore the scan code and respond to the virtual key code, it usually doesn't matter what value is passed as the scan code.

最后,您将要使用SendInput而不是keybd_event.原因是前者允许您在队列中放置一系列事件.使用keybd_event,您可以一次将事件放置在队列中,并且假事件可能散布在真实事件中.而这个问题是引入SendInput的主要原因之一.

Finally, you'll want to use SendInput rather than keybd_event. The reason being that that former allows you to place a sequence of events in the queue. With keybd_event you place the events in the queue one at a time and it's possible that your faked events can get interspersed with real events. And that problem is one of the main reasons why SendInput was introduced.

这篇关于keybd_event中的bScan参数值0x45是什么意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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