[Shortcut Guide] Suppress Windows Menu appearing (#13553)

* Get the new settings values

* Suppress windows menu appearing

* Send new settings telemetry

* Address PR comments
This commit is contained in:
Jaime Bernardo 2021-10-01 14:46:55 +01:00
parent bc7d1bc7b2
commit 03e5e77171
4 changed files with 41 additions and 0 deletions

View file

@ -7,4 +7,6 @@ struct ShortcutGuideSettings
int overlayOpacity = 90;
std::wstring theme = L"system";
std::wstring disabledApps = L"";
bool shouldReactToPressedWinKey = false;
int windowsKeyPressTime = 900;
};

View file

@ -221,6 +221,15 @@ void OverlayWindow::CloseWindow(HideWindowType type, int mainThreadId)
if (this->winkey_popup)
{
if (shouldReactToPressedWinKey.value)
{
// Send a dummy key to prevent Start Menu from activating
INPUT dummyEvent[1] = {};
dummyEvent[0].type = INPUT_KEYBOARD;
dummyEvent[0].ki.wVk = 0xFF;
dummyEvent[0].ki.dwFlags = KEYEVENTF_KEYUP;
SendInput(1, dummyEvent, sizeof(INPUT));
}
this->winkey_popup->SetWindowCloseType(ToWstring(type));
Logger::trace(L"Terminating process");
PostThreadMessage(mainThreadId, WM_QUIT, 0, 0);
@ -300,6 +309,7 @@ void OverlayWindow::init_settings()
overlayOpacity.value = settings.overlayOpacity;
theme.value = settings.theme;
disabledApps.value = settings.disabledApps;
shouldReactToPressedWinKey.value = settings.shouldReactToPressedWinKey;
update_disabled_apps();
}
@ -399,6 +409,22 @@ ShortcutGuideSettings OverlayWindow::GetSettings() noexcept
{
}
try
{
settings.shouldReactToPressedWinKey = properties.GetNamedObject(ShouldReactToPressedWinKey::name).GetNamedBoolean(L"value");
}
catch (...)
{
}
try
{
settings.windowsKeyPressTime = (int)properties.GetNamedObject(WindowsKeyPressTime::name).GetNamedNumber(L"value");
}
catch (...)
{
}
try
{
settings.theme = (std::wstring)properties.GetNamedObject(Theme::name).GetNamedString(L"value");

View file

@ -78,6 +78,17 @@ private:
std::wstring value;
} disabledApps;
struct ShouldReactToPressedWinKey
{
static inline PCWSTR name = L"use_legacy_press_win_key_behavior";
bool value;
} shouldReactToPressedWinKey;
struct WindowsKeyPressTime
{
static inline PCWSTR name = L"press_time";
} windowsKeyPressTime;
struct OpenShortcut
{
static inline PCWSTR name = L"open_shortcutguide";

View file

@ -39,6 +39,8 @@ void Trace::SendSettings(ShortcutGuideSettings settings) noexcept
TraceLoggingInt32(settings.overlayOpacity, "OverlayOpacity"),
TraceLoggingWideString(settings.theme.c_str(), "Theme"),
TraceLoggingWideString(settings.disabledApps.c_str(), "DisabledApps"),
TraceLoggingBoolean(settings.shouldReactToPressedWinKey, "ShouldReactToPressedWinKey"),
TraceLoggingInt32(settings.windowsKeyPressTime, "WindowsKeyPressTime"),
ProjectTelemetryPrivacyDataTag(ProjectTelemetryTag_ProductAndServicePerformance),
TraceLoggingBoolean(TRUE, "UTCReplace_AppSessionGuid"),
TraceLoggingKeyword(PROJECT_KEYWORD_MEASURE));