From e85425050b588a775180699e2d50bf5e60c60f29 Mon Sep 17 00:00:00 2001 From: Jonathan White Date: Thu, 24 Feb 2022 06:50:47 -0500 Subject: [PATCH] Properly press AltGr key in Windows Auto-Type * Fix #7456 --- src/autotype/windows/AutoTypeWindows.cpp | 40 ++++++++++++++---------- src/gui/osutils/winutils/WinUtils.cpp | 2 ++ 2 files changed, 26 insertions(+), 16 deletions(-) diff --git a/src/autotype/windows/AutoTypeWindows.cpp b/src/autotype/windows/AutoTypeWindows.cpp index d7913ff0..894980f8 100644 --- a/src/autotype/windows/AutoTypeWindows.cpp +++ b/src/autotype/windows/AutoTypeWindows.cpp @@ -102,14 +102,18 @@ void AutoTypePlatformWin::sendChar(const QChar& ch, bool isKeyDown) return; } - if (HIBYTE(vkey) & 0x1) { - sendKey(Qt::Key_Shift, true); - } - if (HIBYTE(vkey) & 0x2) { - sendKey(Qt::Key_Control, true); - } - if (HIBYTE(vkey) & 0x4) { - sendKey(Qt::Key_Alt, true); + if (HIBYTE(vkey) & 0x6) { + sendKey(Qt::Key_AltGr, true); + } else { + if (HIBYTE(vkey) & 0x1) { + sendKey(Qt::Key_Shift, true); + } + if (HIBYTE(vkey) & 0x2) { + sendKey(Qt::Key_Control, true); + } + if (HIBYTE(vkey) & 0x4) { + sendKey(Qt::Key_Alt, true); + } } DWORD flags = KEYEVENTF_SCANCODE; @@ -127,14 +131,18 @@ void AutoTypePlatformWin::sendChar(const QChar& ch, bool isKeyDown) ::SendInput(1, &in, sizeof(INPUT)); - if (HIBYTE(vkey) & 0x1) { - sendKey(Qt::Key_Shift, false); - } - if (HIBYTE(vkey) & 0x2) { - sendKey(Qt::Key_Control, false); - } - if (HIBYTE(vkey) & 0x4) { - sendKey(Qt::Key_Alt, false); + if (HIBYTE(vkey) & 0x6) { + sendKey(Qt::Key_AltGr, false); + } else { + if (HIBYTE(vkey) & 0x1) { + sendKey(Qt::Key_Shift, false); + } + if (HIBYTE(vkey) & 0x2) { + sendKey(Qt::Key_Control, false); + } + if (HIBYTE(vkey) & 0x4) { + sendKey(Qt::Key_Alt, false); + } } } diff --git a/src/gui/osutils/winutils/WinUtils.cpp b/src/gui/osutils/winutils/WinUtils.cpp index 3aec7d5f..b2dd9b96 100644 --- a/src/gui/osutils/winutils/WinUtils.cpp +++ b/src/gui/osutils/winutils/WinUtils.cpp @@ -267,6 +267,8 @@ WORD WinUtils::qtToNativeKeyCode(Qt::Key key) return VK_HELP; // 0x2F case Qt::Key_Meta: return VK_LWIN; // 0x5B + case Qt::Key_AltGr: + return VK_RMENU; // 0xA5 case Qt::Key_F1: return VK_F1; // 0x70