ReactOS  0.4.15-dev-4872-g8a3db97
keybd_event.c
Go to the documentation of this file.
1 /*
2  * PROJECT: ReactOS api tests
3  * LICENSE: GPL-2.0-or-later (https://spdx.org/licenses/GPL-2.0-or-later)
4  * PURPOSE: Test for keyboard inputs with flags KEYEVENTF_EXTENDEDKEY and KEYEVENTF_SCANCODE
5  * COPYRIGHT: Copyright 2021 Arjav Garg <arjavgarg@gmail.com>
6  */
7 
8 #include "precomp.h"
9 
10 static void testScancodeExtendedKey(BYTE wVk, BYTE scanCode)
11 {
12  trace("wVK: %x\tScancode: %x\n", wVk, scanCode);
13 
14  keybd_event(0, scanCode, KEYEVENTF_SCANCODE | KEYEVENTF_EXTENDEDKEY, 0);
15  SHORT winKeyState = GetAsyncKeyState(wVk);
16  ok(winKeyState & 0x8000, "VK=%x should be detected as key down.\n", wVk);
17 
18  keybd_event(0, scanCode, KEYEVENTF_SCANCODE | KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP, 0);
19  winKeyState = GetAsyncKeyState(wVk);
20  ok(!(winKeyState & 0x8000), "VK=%x should be detected as key up.\n", wVk);
21 }
22 
23 /* https://docs.microsoft.com/en-us/windows/win32/inputdev/about-keyboard-input#extended-key-flag */
25 {
42 }
#define KEYEVENTF_KEYUP
Definition: winuser.h:1096
#define VK_RMENU
Definition: winuser.h:2267
#define VK_LEFT
Definition: winuser.h:2204
#define VK_LWIN
Definition: winuser.h:2215
#define VK_DOWN
Definition: winuser.h:2207
#define VK_INSERT
Definition: winuser.h:2212
#define VK_PRIOR
Definition: winuser.h:2200
#define VK_RETURN
Definition: winuser.h:2181
#define VK_NEXT
Definition: winuser.h:2201
#define VK_HOME
Definition: winuser.h:2203
#define VK_UP
Definition: winuser.h:2205
static void testScancodeExtendedKey(BYTE wVk, BYTE scanCode)
Definition: keybd_event.c:10
short SHORT
Definition: pedump.c:59
#define VK_DELETE
Definition: winuser.h:2213
#define trace
Definition: atltest.h:70
VOID WINAPI keybd_event(_In_ BYTE, _In_ BYTE, _In_ DWORD, _In_ ULONG_PTR)
#define VK_RCONTROL
Definition: winuser.h:2265
SHORT WINAPI GetAsyncKeyState(_In_ int)
#define VK_RWIN
Definition: winuser.h:2216
unsigned char BYTE
Definition: xxhash.c:193
#define VK_RIGHT
Definition: winuser.h:2206
#define ok(value,...)
Definition: atltest.h:57
#define KEYEVENTF_EXTENDEDKEY
Definition: winuser.h:1095
#define VK_DIVIDE
Definition: winuser.h:2234
START_TEST(keybd_event)
Definition: keybd_event.c:24
#define VK_END
Definition: winuser.h:2202