网站首页  词典首页

请输入您要查询的函数:

 

术语 getkeyboardstate
释义 GetKeyboardState
语法:
BOOL GetKeyboardState( PBYTE lpKeyState
);
GetKeyboardState函数
The GetKeyboardState function copies the status of the 256 virtual keys to the specified buffer.
参数
lpKeyState
[in]指向256字节数组接收为每个虚拟键的状态数据。
返回值
如果函数成功,返回值为非零。
如果函数失败,返回值是零。为了获得更多错误信息,调用GetLastError。
备注
应用程序可以调用这个函数来检索所有的虚拟键的当前状态。作为线程的状态改变其删除消息队列键盘消息。状态没有改变键盘消息被发送到线程的消息队列,也不会改变键盘消息发布到或从其他线程消息队列检索。 (例外:即通过AttachThreadInput共享相同的键盘国家有关的主题。)
当函数返回时,数组中的每个成员提出的lpKeyState参数包含了一个虚拟键的状态数据。如果高序位为1,关键是降低,否则,就到了。如果该键是一个切换键,如CAPS LOCK键,那么低序位为1时,关键是切换和为0,如果是untoggled关键。低序位是没有意义的非切换键。阿切换键被认为是触发时,它处于打开状态。阿切换键的指示灯(如有),在键盘上时,将是关键切换,和关闭时,关键是untoggled。
要检索的各个关键的状态信息,使用GetKeyState函数。要检索的各个关键的当前状态,不管相应的键盘消息已被来自消息队列,使用GetAsyncKeyState功能。
应用程序可以使用的虚拟键码常数VK_SHIFT,VK_CONTROL和VK_MENU作为指标到数组指向lpKeyState。这使无左派和右派之间的区分SHIFT键,Ctrl或Alt键的状态。应用程序也可以使用下面的虚拟键码常数为指标来区分这些键的左,右实例:
VK_LSHIFT
VK_RSHIFT
VK_LCONTROL
VK_RCONTROL
VK_LMENU
VK_RMENU
这些左,右区分常量可用于应用程序只能通过GetKeyboardState,SetKeyboardState,GetAsyncKeyState,GetKeyState和MapVirtualKey功能。
功能信息
最低DLL版本 user32.dll
在Winuser.h中HeaderDeclared,头文件:winuser.h
import libraryUser32.lib
最低操作系统Windows 95,Windows NT 3.1
参见
键盘输入,GetKeyState,GetAsyncKeyState,MapVirtualKey,SetKeyboardState
==英文原文==GetKeyboardState Function
The GetKeyboardState function copies the status of the 256 virtual keys to the specified buffer.
Syntax
BOOL GetKeyboardState( PBYTE lpKeyState
);
Parameters
lpKeyState
[in] Pointer to the 256-byte array that receives the status data for each virtual key.
Return Value
If the function succeeds, the return value is nonzero.
If the function fails, the return value is zero. To get extended error information, call GetLastError .
Remarks
An application can call this function to retrieve the current status of all the virtual keys. The status changes as a thread removes keyboard messages from its message queue. The status does not change as keyboard messages are posted to the thread's message queue, nor does it change as keyboard messages are posted to or retrieved from message queues of other threads. (Exception: Threads that are connected through AttachThreadInput share the same keyboard state.)
When the function returns, each member of the array pointed to by the lpKeyState parameter contains status data for a virtual key. If the high-order bit is 1, the key is down; otherwise, it is up. If the key is a toggle key, for example CAPS LOCK, then the low-order bit is 1 when the key is toggled and is 0 if the key is untoggled. The low-order bit is meaningless for non-toggle keys. A toggle key is said to be toggled when it is turned on. A toggle key's indicator light (if any) on the keyboard will be on when the key is toggled, and off when the key is untoggled.
To retrieve status information for an individual key, use the GetKeyState function. To retrieve the current state for an individual key regardless of whether the corresponding keyboard message has been retrieved from the message queue, use the GetAsyncKeyState function.
An application can use the virtual-key code constants VK_SHIFT, VK_CONTROL and VK_MENU as indices into the array pointed to by lpKeyState. This gives the status of the SHIFT, CTRL, or ALT keys without distinguishing between left and right. An application can also use the following virtual-key code constants as indices to distinguish between the left and right instances of those keys:
VK_LSHIFT
VK_RSHIFT
VK_LCONTROL
VK_RCONTROL
VK_LMENU
VK_RMENU
These left- and right-distinguishing constants are available to an application only through the GetKeyboardState, SetKeyboardState , GetAsyncKeyState, GetKeyState, and MapVirtualKey functions.
Function Information
Minimum DLL Versionuser32.dll
HeaderDeclared in Winuser.h, include Windows.h
Import libraryUser32.lib
Minimum operating systemsWindows 95, Windows NT 3.1
See Also
Keyboard Input , GetKeyState , GetAsyncKeyState , MapVirtualKey , SetKeyboardState
==原始网址==http://msdn.microsoft.com/en-us/library/ms646299(VS.85).aspx\n
随便看

 

windows api函数参考手册包含2258条windows api函数文档,详细介绍nodejs、java、rust调用windows api的方法技巧,是学习windows api编程的入门中文文档。

 

Copyright © 2004-2023 Winrtm.com All Rights Reserved
京ICP备2021023879号-40 更新时间:2024/10/6 11:26:39