ReactOS  0.4.14-dev-358-gbef841c
RegisterHotKey.c File Reference
#include "precomp.h"
Include dependency graph for RegisterHotKey.c:

Go to the source code of this file.

Macros

#define msg_hotkey(msg, id, mod, vk)
 
#define expect_hotkey(id, mod, vk)
 
#define msg_no_hotkey(msg)
 
#define expect_no_hotkey()
 

Functions

 START_TEST (RegisterHotKey)
 

Macro Definition Documentation

◆ expect_hotkey

#define expect_hotkey (   id,
  mod,
  vk 
)
Value:
do \
{ \
MSG msg; \
int hotkey_count = 0; \
while (PeekMessage(&msg, 0, 0, 0, PM_REMOVE)) \
{ \
msg_hotkey(&msg, id, mod, vk); \
if (msg.message == WM_HOTKEY) hotkey_count++; \
DispatchMessageW(&msg); \
} \
ok(hotkey_count == 1, "Received %d WM_HOTKEY messages, expected 1\n", hotkey_count); \
} while (0)
#define PeekMessage
Definition: winuser.h:5731
#define WM_HOTKEY
Definition: winuser.h:1861
#define msg(x)
Definition: auth_time.c:54
#define PM_REMOVE
Definition: winuser.h:1182
static int mod
Definition: i386-dis.c:1273

Definition at line 18 of file RegisterHotKey.c.

◆ expect_no_hotkey

#define expect_no_hotkey ( )
Value:
do \
{ \
MSG msg; \
while (PeekMessage(&msg, 0, 0, 0, PM_REMOVE)) \
{ \
msg_no_hotkey(&msg); \
DispatchMessageW(&msg); \
} \
} while (0)
#define PeekMessage
Definition: winuser.h:5731
#define msg(x)
Definition: auth_time.c:54
#define PM_REMOVE
Definition: winuser.h:1182

Definition at line 41 of file RegisterHotKey.c.

◆ msg_hotkey

#define msg_hotkey (   msg,
  id,
  mod,
  vk 
)
Value:
do \
{ \
ok((msg)->message == WM_HOTKEY, "Unexpected message %u\n", (msg)->message); \
ok((msg)->hwnd == NULL, "hwnd = %p\n", (msg)->hwnd); \
ok((msg)->wParam == (id), "wParam = 0x%Ix\n", (msg)->wParam); \
ok((msg)->lParam == MAKELONG(mod, vk), \
"wParam = 0x%Ix, expected 0x%lx\n", (msg)->lParam, MAKELONG(mod, vk)); \
} while (0)
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
Definition: tftpd.h:59
#define WM_HOTKEY
Definition: winuser.h:1861
WPARAM wParam
Definition: combotst.c:138
#define MAKELONG(a, b)
Definition: typedefs.h:248
smooth NULL
Definition: ftsmooth.c:416
#define msg(x)
Definition: auth_time.c:54
LPARAM lParam
Definition: combotst.c:139
static int mod
Definition: i386-dis.c:1273

Definition at line 10 of file RegisterHotKey.c.

◆ msg_no_hotkey

#define msg_no_hotkey (   msg)
Value:
do \
{ \
if ((msg)->message == WM_HOTKEY) \
ok((msg)->message != WM_HOTKEY, \
"Got WM_HOTKEY with hwnd=%p, wParam=0x%Ix, lParam=0x%Ix\n", \
(msg)->hwnd, (msg)->wParam, (msg)->lParam); \
ok(0, \
"Unexpected message %u posted to thread with hwnd=%p, wParam=0x%Ix, lParam=0x%Ix\n", \
(msg)->message, (msg)->hwnd, (msg)->wParam, (msg)->lParam); \
} while (0)
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
Definition: tftpd.h:59
#define WM_HOTKEY
Definition: winuser.h:1861
WPARAM wParam
Definition: combotst.c:138
#define ok(value,...)
Definition: atltest.h:57
#define msg(x)
Definition: auth_time.c:54
LPARAM lParam
Definition: combotst.c:139

Definition at line 30 of file RegisterHotKey.c.

Function Documentation

◆ START_TEST()

START_TEST ( RegisterHotKey  )

Definition at line 51 of file RegisterHotKey.c.

52 {
53  SetCursorPos(0, 0);
54 
59 
61 
62  trace("Ctrl only\n");
63  keybd_event(VK_CONTROL, 0, 0, 0);
67 
68  trace("Ctrl+U\n");
69  keybd_event(VK_CONTROL, 0, 0, 0);
71  keybd_event('U', 0, 0, 0);
72  expect_hotkey(2, MOD_CONTROL, 'U');
73  keybd_event('U', 0, KEYEVENTF_KEYUP, 0);
77 
78  trace("Ctrl+U (with Ctrl up first)\n");
79  keybd_event(VK_CONTROL, 0, 0, 0);
81  keybd_event('U', 0, 0, 0);
82  expect_hotkey(2, MOD_CONTROL, 'U');
85  keybd_event('U', 0, KEYEVENTF_KEYUP, 0);
87 
88  trace("Ctrl+U (with U down first and Ctrl up first)\n");
89  keybd_event('U', 0, 0, 0);
91  keybd_event(VK_CONTROL, 0, 0, 0);
95  keybd_event('U', 0, KEYEVENTF_KEYUP, 0);
97 
98  trace("Ctrl+U (with U down first and U up first)\n");
99  keybd_event('U', 0, 0, 0);
101  keybd_event(VK_CONTROL, 0, 0, 0);
103  keybd_event('U', 0, KEYEVENTF_KEYUP, 0);
107 
108  trace("Ctrl+Alt\n");
109  keybd_event(VK_CONTROL, 0, 0, 0);
111  keybd_event(VK_MENU, 0, 0, 0);
117 
118  trace("Ctrl+Alt (with Ctrl up first)\n");
119  keybd_event(VK_CONTROL, 0, 0, 0);
121  keybd_event(VK_MENU, 0, 0, 0);
127 
128  trace("Alt+Ctrl\n");
129  keybd_event(VK_MENU, 0, 0, 0);
131  keybd_event(VK_CONTROL, 0, 0, 0);
137 
138  trace("Alt+Ctrl (with Alt up first)\n");
139  keybd_event(VK_MENU, 0, 0, 0);
141  keybd_event(VK_CONTROL, 0, 0, 0);
147 
148  trace("Alt+U\n");
149  keybd_event(VK_MENU, 0, 0, 0);
151  keybd_event('U', 0, 0, 0);
153  keybd_event('U', 0, KEYEVENTF_KEYUP, 0);
157 
158  trace("Ctrl+Alt+U\n");
159  keybd_event(VK_CONTROL, 0, 0, 0);
161  keybd_event(VK_MENU, 0, 0, 0);
163  keybd_event('U', 0, 0, 0);
164  expect_hotkey(4, MOD_CONTROL | MOD_ALT, 'U');
165  keybd_event('U', 0, KEYEVENTF_KEYUP, 0);
171 
172  trace("Alt+Ctrl+U\n");
173  keybd_event(VK_MENU, 0, 0, 0);
175  keybd_event(VK_CONTROL, 0, 0, 0);
177  keybd_event('U', 0, 0, 0);
178  expect_hotkey(4, MOD_CONTROL | MOD_ALT, 'U');
179  keybd_event('U', 0, KEYEVENTF_KEYUP, 0);
185 
186  trace("Ctrl+U+Alt\n");
187  keybd_event(VK_CONTROL, 0, 0, 0);
189  keybd_event('U', 0, 0, 0);
190  expect_hotkey(2, MOD_CONTROL, 'U');
191  keybd_event(VK_MENU, 0, 0, 0);
195  keybd_event('U', 0, KEYEVENTF_KEYUP, 0);
199 
200  trace("Alt+U+Ctrl\n");
201  keybd_event(VK_MENU, 0, 0, 0);
203  keybd_event('U', 0, 0, 0);
205  keybd_event(VK_CONTROL, 0, 0, 0);
209  keybd_event('U', 0, KEYEVENTF_KEYUP, 0);
213 
214  /* The remaining combinations are an exercise left to the reader */
215 
220 
222 }
#define KEYEVENTF_KEYUP
Definition: winuser.h:1092
#define VK_MENU
Definition: winuser.h:2179
BOOL WINAPI UnregisterHotKey(_In_opt_ HWND, _In_ int)
smooth NULL
Definition: ftsmooth.c:416
#define trace
Definition: atltest.h:70
VOID WINAPI keybd_event(_In_ BYTE, _In_ BYTE, _In_ DWORD, _In_ ULONG_PTR)
BOOL WINAPI SetCursorPos(_In_ int, _In_ int)
Definition: cursoricon.c:2627
#define MOD_ALT
Definition: imm.h:311
#define MOD_CONTROL
Definition: imm.h:312
#define VK_CONTROL
Definition: winuser.h:2178
#define expect_hotkey(id, mod, vk)
BOOL WINAPI RegisterHotKey(_In_opt_ HWND, _In_ int, _In_ UINT, _In_ UINT)
#define expect_no_hotkey()