From d5493506b670c5da6599b7d12ced1dcc70879d21 Mon Sep 17 00:00:00 2001 From: user202729 <25191436+user202729@users.noreply.github.com> Date: Fri, 18 Jun 2021 09:45:11 +0700 Subject: [PATCH 1/3] Do not consider extended scan codes in Windows --- plover/oslayer/windows/keyboardcontrol.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/plover/oslayer/windows/keyboardcontrol.py b/plover/oslayer/windows/keyboardcontrol.py index 14067456d..33478dbeb 100644 --- a/plover/oslayer/windows/keyboardcontrol.py +++ b/plover/oslayer/windows/keyboardcontrol.py @@ -102,6 +102,11 @@ class INPUT(ctypes.Structure): INPUT_MOUSE = 0 INPUT_KEYBOARD = 1 +KF_EXTENDED = 0x0100 +LLKHF_EXTENDED = KF_EXTENDED >> 8 +LLKHF_LOWER_IL_INJECTED = 0x0002 +LLKHF_INJECTED = 0x0010 + # Process utils code code based on psutil implementation. @@ -318,6 +323,9 @@ def _run(self): passthrough_down_keys = set() def on_key(pressed, event): + if event.flags & LLKHF_EXTENDED: + return False + if event.flags & 0x10: # Ignore simulated events (e.g. from KeyboardEmulation). return False From 7353fc91010f0698a727c6f8c0acba6effdaaa63 Mon Sep 17 00:00:00 2001 From: user202729 <25191436+user202729@users.noreply.github.com> Date: Fri, 18 Jun 2021 09:45:49 +0700 Subject: [PATCH 2/3] Change 0x10 constant to LLKHF_INJECTED constant name in Windows oslayer keyboard handling --- plover/oslayer/windows/keyboardcontrol.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plover/oslayer/windows/keyboardcontrol.py b/plover/oslayer/windows/keyboardcontrol.py index 33478dbeb..8dddf8998 100644 --- a/plover/oslayer/windows/keyboardcontrol.py +++ b/plover/oslayer/windows/keyboardcontrol.py @@ -326,7 +326,7 @@ def on_key(pressed, event): if event.flags & LLKHF_EXTENDED: return False - if event.flags & 0x10: + if event.flags & LLKHF_INJECTED: # Ignore simulated events (e.g. from KeyboardEmulation). return False if event.vkCode in PASSTHROUGH_KEYS: From d8fa159066b9690af17f27e7144c4a0576c395f4 Mon Sep 17 00:00:00 2001 From: user202729 <25191436+user202729@users.noreply.github.com> Date: Fri, 18 Jun 2021 09:49:13 +0700 Subject: [PATCH 3/3] Add news fragment --- news.d/bugfix/1357.windows.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 news.d/bugfix/1357.windows.md diff --git a/news.d/bugfix/1357.windows.md b/news.d/bugfix/1357.windows.md new file mode 100644 index 000000000..7cc78a791 --- /dev/null +++ b/news.d/bugfix/1357.windows.md @@ -0,0 +1 @@ +Do not consider extended scan codes in Windows keyboard capture.