From bd09be4fae1f57c26eac54e147409eeb918eaa83 Mon Sep 17 00:00:00 2001 From: Jonathan White Date: Wed, 23 Mar 2022 21:44:50 -0400 Subject: [PATCH 1/2] Fix Auto-Type modifiers on Windows Also add documentation on modifiers. * Fix #7626 --- docs/topics/AutoType.adoc | 12 ++++++++++++ docs/topics/Reference.adoc | 9 +++++++++ src/autotype/windows/AutoTypeWindows.cpp | 2 +- 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/docs/topics/AutoType.adoc b/docs/topics/AutoType.adoc index 62d2aef0f9..836d2c7d15 100644 --- a/docs/topics/AutoType.adoc +++ b/docs/topics/AutoType.adoc @@ -68,6 +68,18 @@ image::autotype_entry_sequences.png[] |{PICKCHARS} |Pick specific password characters from a dialog |{MODE=VIRTUAL} |(Experimental) Use virtual key presses on Windows, useful for virtual machines |=== ++ +[grid=rows, frame=none, width=90%] +|=== +|Modifier |Description + +|+ |SHIFT +|^ |CTRL +|% |ALT +|# |WIN/CMD +|=== + +TIP: Use modifiers to hold down special keys before typing the next character. For example, to type *CTRL+SHIFT+D* use: `^+d`. This is useful if you need to activate certain actions in a program or on your desktop. === Performing Global Auto-Type The global Auto-Type keyboard shortcut is used when you have focus on the window you want to type into. To make use of this feature, you must have previously configured an Auto-Type hotkey. diff --git a/docs/topics/Reference.adoc b/docs/topics/Reference.adoc index 666b846dc0..c123befc46 100644 --- a/docs/topics/Reference.adoc +++ b/docs/topics/Reference.adoc @@ -84,6 +84,15 @@ Examples: + |{PICKCHARS} |Pick specific password characters from a dialog |=== +[grid=rows, frame=none, width=90%] +|=== +|Modifier |Description + +|+ |SHIFT +|^ |CTRL +|% |ALT +|# |WIN/CMD +|=== *Text Conversions:* `{T-CONV:/<PLACEHOLDER>/<METHOD>/}` + diff --git a/src/autotype/windows/AutoTypeWindows.cpp b/src/autotype/windows/AutoTypeWindows.cpp index 3f816417d0..a18ec2454c 100644 --- a/src/autotype/windows/AutoTypeWindows.cpp +++ b/src/autotype/windows/AutoTypeWindows.cpp @@ -297,7 +297,7 @@ AutoTypeAction::Result AutoTypeExecutorWin::execType(const AutoTypeKey* action) m_platform->setKeyState(action->key, true); m_platform->setKeyState(action->key, false); } else { - if (mode == Mode::VIRTUAL) { + if (mode == Mode::VIRTUAL || action->modifiers != Qt::NoModifier) { m_platform->sendCharVirtual(action->character); } else { m_platform->sendChar(action->character); From 91ebc7be9d9c82a03307ba40f8780502e26309d0 Mon Sep 17 00:00:00 2001 From: Jonathan White Date: Thu, 31 Mar 2022 18:18:33 -0400 Subject: [PATCH 2/2] Fix Auto-Typing single character placeholders * Fix #7743 - Include # in placeholder list * This change fixes typing single character placeholders (escaped placeholders) on Windows. Previously we were sending these as raw key presses which didn't properly press Shift or other modifiers. Now they are sent as unicode characters unless in virtual mode (the expected behavior). --- src/autotype/AutoType.cpp | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/src/autotype/AutoType.cpp b/src/autotype/AutoType.cpp index 7764284c2d..102cd95abe 100644 --- a/src/autotype/AutoType.cpp +++ b/src/autotype/AutoType.cpp @@ -72,19 +72,20 @@ namespace {"multiply", Qt::Key_Asterisk}, {"divide", Qt::Key_Slash}, {"leftbrace", Qt::Key_BraceLeft}, - {"{", Qt::Key_BraceLeft}, + {"{", Qt::Key_unknown}, {"rightbrace", Qt::Key_BraceRight}, - {"}", Qt::Key_BraceRight}, + {"}", Qt::Key_unknown}, {"leftparen", Qt::Key_ParenLeft}, - {"(", Qt::Key_ParenLeft}, + {"(", Qt::Key_unknown}, {"rightparen", Qt::Key_ParenRight}, - {")", Qt::Key_ParenRight}, - {"[", Qt::Key_BracketLeft}, - {"]", Qt::Key_BracketRight}, - {"+", Qt::Key_Plus}, - {"%", Qt::Key_Percent}, - {"^", Qt::Key_AsciiCircum}, - {"~", Qt::Key_AsciiTilde}, + {")", Qt::Key_unknown}, + {"[", Qt::Key_unknown}, + {"]", Qt::Key_unknown}, + {"+", Qt::Key_unknown}, + {"%", Qt::Key_unknown}, + {"^", Qt::Key_unknown}, + {"~", Qt::Key_unknown}, + {"#", Qt::Key_unknown}, {"numpad0", Qt::Key_0}, {"numpad1", Qt::Key_1}, {"numpad2", Qt::Key_2}, @@ -612,7 +613,12 @@ AutoType::parseSequence(const QString& entrySequence, const Entry* entry, QStrin error = tr("Too many repetitions detected, max is %1: %2").arg(maxRepetition).arg(fullPlaceholder); return {}; } - auto action = QSharedPointer::create(g_placeholderToKey[placeholder], modifiers); + QSharedPointer action; + if (g_placeholderToKey[placeholder] == Qt::Key_unknown) { + action = QSharedPointer::create(placeholder[0], modifiers); + } else { + action = QSharedPointer::create(g_placeholderToKey[placeholder], modifiers); + } for (int i = 1; i <= repeat && i <= maxRepetition; ++i) { actions << action; }