Changed dummy key event to send key down and key up to improve compatibility with applications (#7166)

This commit is contained in:
Arjun Balgovind
2020-10-08 11:28:37 -07:00
committed by GitHub
parent e1d22c74b0
commit 42ebc42c98
4 changed files with 33 additions and 25 deletions

View File

@@ -6,6 +6,7 @@
#include "../../common/common.h"
#include "keyboardmanager/dll/Generated Files/resource.h"
#include "../common/keyboard_layout.h"
#include "KeyboardManagerConstants.h"
extern "C" IMAGE_DOS_HEADER __ImageBase;
using namespace winrt::Windows::Foundation;
@@ -193,6 +194,15 @@ namespace KeyboardManagerHelper
keyEventArray[index].ki.dwExtraInfo = extraInfo;
}
// Function to set the dummy key events used for remapping shortcuts, required to ensure releasing a modifier doesn't trigger another action (For example, Win->Start Menu or Alt->Menu bar)
void SetDummyKeyEvent(LPINPUT keyEventArray, int& index, ULONG_PTR extraInfo)
{
SetKeyEvent(keyEventArray, index, INPUT_KEYBOARD, (WORD)KeyboardManagerConstants::DUMMY_KEY, 0, extraInfo);
index++;
SetKeyEvent(keyEventArray, index, INPUT_KEYBOARD, (WORD)KeyboardManagerConstants::DUMMY_KEY, KEYEVENTF_KEYUP, extraInfo);
index++;
}
// Function to return window handle for a full screen UWP app
HWND GetFullscreenUWPWindowHandle()
{

View File

@@ -87,6 +87,9 @@ namespace KeyboardManagerHelper
// Function to set the value of a key event based on the arguments
void SetKeyEvent(LPINPUT keyEventArray, int index, DWORD inputType, WORD keyCode, DWORD flags, ULONG_PTR extraInfo);
// Function to set the dummy key events used for remapping shortcuts, required to ensure releasing a modifier doesn't trigger another action (For example, Win->Start Menu or Alt->Menu bar)
void SetDummyKeyEvent(LPINPUT keyEventArray, int& index, ULONG_PTR extraInfo);
// Function to return window handle for a full screen UWP app
HWND GetFullscreenUWPWindowHandle();

View File

@@ -100,6 +100,9 @@ namespace KeyboardManagerConstants
// Dummy key event used in between key up and down events to prevent certain global events from happening
inline const DWORD DUMMY_KEY = 0xFF;
// Number of key messages required while sending a dummy key event
inline const size_t DUMMY_KEY_EVENT_SIZE = 2;
// String constant for the default app name in Remap shortcuts
inline const std::wstring DefaultAppName = GET_RESOURCE_STRING(IDS_EDITSHORTCUTS_ALLAPPS);