Monday, February 15, 2010

Virtual-Key Codes, c++, windows

--------------------
Constant Definitions
--------------------
Const KEYEVENTF_EXTENDEDKEY = &H1
Const KEYEVENTF_KEYUP = &H2
Example
' Simulate the user pressing Alt+Space followed by N. This
' key combination will minimize the active window.
' Hold the Alt key while typing Space.
keybd_event VK_MENU, 0, 0, 0 ' press Alt
keybd_event VK_SPACE, 0, 0, 0 ' press Space
keybd_event VK_SPACE, 0, KEYEVENTF_KEYUP, 0 ' release Space
keybd_event VK_MENU, 0, KEYEVENTF_KEYUP, 0 ' release Alt
' Type the N key.
keybd_event VK_N, 0, 0, 0 ' press N
keybd_event VK_N, 0, KEYEVENTF_KEYUP, 0 ' release N
-----------------
Virtual-Key Codes
-----------------
Description & Usage
The virtual-key codes identify various virtual keys. Virtual keys mainly
consist of actual keyboard keys, but also include "virtual" elements such
as the three mouse buttons. The virtual keys also include many "keys"
which usually do not exist at all! A key's virtual-key code does not
change when modifier keys (Ctrl, Alt, Shift, etc.) are held -- e.g.,
the 1 key has the same virtual-key code whether 1 or ! is pressed. However,
the numbers in the numeric keypad on the keyboard do have two different
virtual-key codes: one for when Num Lock is on, and another for when Num
Lock is off. Note that the virtual-key codes of 0-9 and A-Z equal their
ASCII codes.
Note: The actual meanings of some of the key codes may vary on keyboards
designed for different languages. Most notably, the VK_OEM_* that denote
punctuation keys may vary between languages, relating to a different
punctuation key. The meanings listed below are for a U.S. English-language
keyboard.
-----------------
Virtual Key Codes
-----------------
VK_LBUTTON
The left mouse button
VK_RBUTTON
The right mouse button
VK_CANCEL
The Cancel virtual key, used for control-break processing
VK_MBUTTON
The middle mouse button
VK_BACK
Backspace
VK_TAB
Tab
VK_CLEAR
5 (keypad without Num Lock)
VK_RETURN
Enter
VK_SHIFT
Shift (either one)
VK_CONTROL
Ctrl (either one)
VK_MENU
Alt (either one)
VK_PAUSE
Pause
VK_CAPITAL
Caps Lock
VK_ESCAPE
Esc
VK_SPACE
Spacebar
VK_PRIOR
Page Up
VK_NEXT
Page Down
VK_END
End
VK_HOME
Home
VK_LEFT
Left Arrow
VK_UP
Up Arrow
VK_RIGHT
Right Arrow
VK_DOWN
Down Arrow
VK_SELECT
Select
VK_PRINT
Print (only used by Nokia keyboards)
VK_EXECUTE
Execute (not used)
VK_SNAPSHOT
Print Screen
VK_INSERT
Insert
VK_DELETE
Delete
VK_HELP
Help
VK_0
0
VK_1
1
VK_2
2
VK_3
3
VK_4
4
VK_5
5
VK_6
6
VK_7
7
VK_8
8
VK_9
9
VK_A
A
VK_B
B
VK_C
C
VK_D
D
VK_E
E
VK_F
F
VK_G
G
VK_H
H
VK_I
I
VK_J
J
VK_K
K
VK_L
L
VK_M
M
VK_N
N
VK_O
O
VK_P
P
VK_Q
Q
VK_R
R
VK_S
S
VK_T
T
VK_U
U
VK_V
V
VK_W
W
VK_X
X
VK_Y
Y
VK_Z
Z
VK_STARTKEY
Start Menu key
VK_CONTEXTKEY
Context Menu key
VK_NUMPAD0
0 (keypad with Num Lock)
VK_NUMPAD1
1 (keypad with Num Lock)
VK_NUMPAD2
2 (keypad with Num Lock)
VK_NUMPAD3
3 (keypad with Num Lock)
VK_NUMPAD4
4 (keypad with Num Lock)
VK_NUMPAD5
5 (keypad with Num Lock)
VK_NUMPAD6
6 (keypad with Num Lock)
VK_NUMPAD7
7 (keypad with Num Lock)
VK_NUMPAD8
8 (keypad with Num Lock)
VK_NUMPAD9
9 (keypad with Num Lock)
VK_MULTIPLY
* (keypad)
VK_ADD
+ (keypad)
VK_SEPARATER
Separator (never generated by the keyboard)
VK_DECIMAL
. (keypad with Num Lock)
VK_DIVIDE
/ (keypad)
VK_F1
F1
VK_F2
F2
VK_F3
F3
VK_F4
F4
VK_F5
F5
VK_F6
F6
VK_F7
F7
VK_F8
F8
VK_F9
F9
VK_F10
F10
VK_F11
F11
VK_F12
F12
VK_F13
F13
VK_F14
F14
VK_F15
F15
VK_F16
F16
VK_F17
F17
VK_F18
F18
VK_F19
F19
VK_F20
F20
VK_F21
F21
VK_F22
F22
VK_F23
F23
VK_F24
F24
VK_NUMLOCK
Num Lock
VK_OEM_SCROLL
Scroll Lock
VK_OEM_1
;
VK_OEM_PLUS
=
VK_OEM_COMMA
,
VK_OEM_MINUS
-
VK_OEM_PERIOD
.
VK_OEM_2
/
VK_OEM_3
`
VK_OEM_4
[
VK_OEM_5
\
VK_OEM_6
]
VK_OEM_7
'
VK_OEM_8
(unknown)
VK_ICO_F17
F17 on Olivetti extended keyboard (internal use only)
VK_ICO_F18
F18 on Olivetti extended keyboard (internal use only)
VK_OEM_102
< or on IBM-compatible 102 enhanced non-U.S. keyboard
VK_ICO_HELP
Help on Olivetti extended keyboard (internal use only)
VK_ICO_00
00 on Olivetti extended keyboard (internal use only)
VK_ICO_CLEAR
Clear on Olivette extended keyboard (internal use only)
VK_OEM_RESET
Reset (Nokia keyboards only)
VK_OEM_JUMP
Jump (Nokia keyboards only)
VK_OEM_PA1
PA1 (Nokia keyboards only)
VK_OEM_PA2
PA2 (Nokia keyboards only)
VK_OEM_PA3
PA3 (Nokia keyboards only)
VK_OEM_WSCTRL
WSCTRL (Nokia keyboards only)
VK_OEM_CUSEL
CUSEL (Nokia keyboards only)
VK_OEM_ATTN
ATTN (Nokia keyboards only)
VK_OEM_FINNISH
FINNISH (Nokia keyboards only)
VK_OEM_COPY
COPY (Nokia keyboards only)
VK_OEM_AUTO
AUTO (Nokia keyboards only)
VK_OEM_ENLW
ENLW (Nokia keyboards only)
VK_OEM_BACKTAB
BACKTAB (Nokia keyboards only)
VK_ATTN
ATTN
VK_CRSEL
CRSEL
VK_EXSEL
EXSEL
VK_EREOF
EREOF
VK_PLAY
PLAY
VK_ZOOM
ZOOM
VK_NONAME
NONAME
VK_PA1
PA1
VK_OEM_CLEAR
CLEAR
Constant Definitions
Const VK_LBUTTON = &H1
Const VK_RBUTTON = &H2
Const VK_CANCEL = &H3
Const VK_MBUTTON = &H4
Const VK_BACK = &H8
Const VK_TAB = &H9
Const VK_CLEAR = &HC
Const VK_RETURN = &HD
Const VK_SHIFT = &H10
Const VK_CONTROL = &H11
Const VK_MENU = &H12
Const VK_PAUSE = &H13
Const VK_CAPITAL = &H14
Const VK_ESCAPE = &H1B
Const VK_SPACE = &H20
Const VK_PRIOR = &H21
Const VK_NEXT = &H22
Const VK_END = &H23
Const VK_HOME = &H24
Const VK_LEFT = &H25
Const VK_UP = &H26
Const VK_RIGHT = &H27
Const VK_DOWN = &H28
Const VK_SELECT = &H29
Const VK_PRINT = &H2A
Const VK_EXECUTE = &H2B
Const VK_SNAPSHOT = &H2C
Const VK_INSERT = &H2D
Const VK_DELETE = &H2E
Const VK_HELP = &H2F
Const VK_0 = &H30
Const VK_1 = &H31
Const VK_2 = &H32
Const VK_3 = &H33
Const VK_4 = &H34
Const VK_5 = &H35
Const VK_6 = &H36
Const VK_7 = &H37
Const VK_8 = &H38
Const VK_9 = &H39
Const VK_A = &H41
Const VK_B = &H42
Const VK_C = &H43
Const VK_D = &H44
Const VK_E = &H45
Const VK_F = &H46
Const VK_G = &H47
Const VK_H = &H48
Const VK_I = &H49
Const VK_J = &H4A
Const VK_K = &H4B
Const VK_L = &H4C
Const VK_M = &H4D
Const VK_N = &H4E
Const VK_O = &H4F
Const VK_P = &H50
Const VK_Q = &H51
Const VK_R = &H52
Const VK_S = &H53
Const VK_T = &H54
Const VK_U = &H55
Const VK_V = &H56
Const VK_W = &H57
Const VK_X = &H58
Const VK_Y = &H59
Const VK_Z = &H5A
Const VK_STARTKEY = &H5B
Const VK_CONTEXTKEY = &H5D
Const VK_NUMPAD0 = &H60
Const VK_NUMPAD1 = &H61
Const VK_NUMPAD2 = &H62
Const VK_NUMPAD3 = &H63
Const VK_NUMPAD4 = &H64
Const VK_NUMPAD5 = &H65
Const VK_NUMPAD6 = &H66
Const VK_NUMPAD7 = &H67
Const VK_NUMPAD8 = &H68
Const VK_NUMPAD9 = &H69
Const VK_MULTIPLY = &H6A
Const VK_ADD = &H6B
Const VK_SEPARATOR = &H6C
Const VK_SUBTRACT = &H6D
Const VK_DECIMAL = &H6E
Const VK_DIVIDE = &H6F
Const VK_F1 = &H70
Const VK_F2 = &H71
Const VK_F3 = &H72
Const VK_F4 = &H73
Const VK_F5 = &H74
Const VK_F6 = &H75
Const VK_F7 = &H76
Const VK_F8 = &H77
Const VK_F9 = &H78
Const VK_F10 = &H79
Const VK_F11 = &H7A
Const VK_F12 = &H7B
Const VK_F13 = &H7C
Const VK_F14 = &H7D
Const VK_F15 = &H7E
Const VK_F16 = &H7F
Const VK_F17 = &H80
Const VK_F18 = &H81
Const VK_F19 = &H82
Const VK_F20 = &H83
Const VK_F21 = &H84
Const VK_F22 = &H85
Const VK_F23 = &H86
Const VK_F24 = &H87
Const VK_NUMLOCK = &H90
Const VK_OEM_SCROLL = &H91
Const VK_OEM_1 = &HBA
Const VK_OEM_PLUS = &HBB
Const VK_OEM_COMMA = &HBC
Const VK_OEM_MINUS = &HBD
Const VK_OEM_PERIOD = &HBE
Const VK_OEM_2 = &HBF
Const VK_OEM_3 = &HC0
Const VK_OEM_4 = &HDB
Const VK_OEM_5 = &HDC
Const VK_OEM_6 = &HDD
Const VK_OEM_7 = &HDE
Const VK_OEM_8 = &HDF
Const VK_ICO_F17 = &HE0
Const VK_ICO_F18 = &HE1
Const VK_OEM102 = &HE2
Const VK_ICO_HELP = &HE3
Const VK_ICO_00 = &HE4
Const VK_ICO_CLEAR = &HE6
Const VK_OEM_RESET = &HE9
Const VK_OEM_JUMP = &HEA
Const VK_OEM_PA1 = &HEB
Const VK_OEM_PA2 = &HEC
Const VK_OEM_PA3 = &HED
Const VK_OEM_WSCTRL = &HEE
Const VK_OEM_CUSEL = &HEF
Const VK_OEM_ATTN = &HF0
Const VK_OEM_FINNISH = &HF1
Const VK_OEM_COPY = &HF2
Const VK_OEM_AUTO = &HF3
Const VK_OEM_ENLW = &HF4
Const VK_OEM_BACKTAB = &HF5
Const VK_ATTN = &HF6
Const VK_CRSEL = &HF7
Const VK_EXSEL = &HF8
Const VK_EREOF = &HF9
Const VK_PLAY = &HFA
Const VK_ZOOM = &HFB
Const VK_NONAME = &HFC
Const VK_PA1 = &HFD
Const VK_OEM_CLEAR = &HFE

No comments: