函数参考


_WinAPI_MapVirtualKey

Translates a virtual-key code into a scan code or character value, or translates a scan code into a virtual-key code.

#Include <WinAPIEx.au3>
_WinAPI_MapVirtualKey ( $iCode, $iType )

参数

$iCode The virtual key code or scan code for a key. How this value is interpreted depends on the $iType parameter.
$iType The translation to be performed. This value depends on the value of the $iCode parameter and can be
one of the following values.

$MAPVK_VK_TO_CHAR
$MAPVK_VK_TO_VSC
$MAPVK_VSC_TO_VK
$MAPVK_VSC_TO_VK_EX

返回值

Success A scan code, a virtual-key code, or a character value, depending on the above parameters.
失败: 返回 0 并设置 @error 标志为非 0 值.

注意/说明

An application can use _WinAPI_MapVirtualKey() to translate scan codes to the virtual-key code constants
$VK_SHIFT, $VK_CONTROL, and $VK_MENU, and vice versa. These translations do not distinguish between the left and
right instances of the SHIFT, CTRL, or ALT keys.

An application can get the scan code corresponding to the left or right instance of one of these keys by calling
_WinAPI_MapVirtualKey() with uCode set to one of the following virtual-key code constants.

$VK_LSHIFT
$VK_RSHIFT
$VK_LCONTROL
$VK_RCONTROL
$VK_LMENU
$VK_RMENU

相关

详情参考

在MSDN中搜索


示例/演示


#Include <APIConstants.au3>
#Include <WinAPIEx.au3>

ConsoleWrite('Virtual-key code: 0x' & Hex($VK_A) & @CR)
ConsoleWrite('Scan code: 0x' & Hex(_WinAPI_MapVirtualKey($VK_A, $MAPVK_VK_TO_VSC)) & @CR)