diff --git a/src/modules/pasteplain/PastePlainModuleInterface/dllmain.cpp b/src/modules/pasteplain/PastePlainModuleInterface/dllmain.cpp index 1ad6578c82..555e156bf6 100644 --- a/src/modules/pasteplain/PastePlainModuleInterface/dllmain.cpp +++ b/src/modules/pasteplain/PastePlainModuleInterface/dllmain.cpp @@ -165,6 +165,18 @@ private: } } + void try_inject_modifier_key_restore(std::vector &inputs, short modifier) + { + // Most significant bit is set if key is down + if ((GetAsyncKeyState(static_cast(modifier)) & 0x8000) != 0) + { + INPUT input_event = {}; + input_event.type = INPUT_KEYBOARD; + input_event.ki.wVk = modifier; + inputs.push_back(input_event); + } + } + void try_to_paste_as_plain_text() { std::wstring clipboard_text; @@ -334,6 +346,15 @@ private: inputs.push_back(input_event); } + try_inject_modifier_key_restore(inputs, VK_LCONTROL); + try_inject_modifier_key_restore(inputs, VK_RCONTROL); + try_inject_modifier_key_restore(inputs, VK_LWIN); + try_inject_modifier_key_restore(inputs, VK_RWIN); + try_inject_modifier_key_restore(inputs, VK_LSHIFT); + try_inject_modifier_key_restore(inputs, VK_RSHIFT); + try_inject_modifier_key_restore(inputs, VK_LMENU); + try_inject_modifier_key_restore(inputs, VK_RMENU); + auto uSent = SendInput(static_cast(inputs.size()), inputs.data(), sizeof(INPUT)); if (uSent != inputs.size()) {