From 7a6ec18a35c2c937776173636e18d2a0334a00b3 Mon Sep 17 00:00:00 2001 From: qianlifeng Date: Thu, 14 Nov 2024 00:01:33 +0800 Subject: [PATCH] Prevent the error/beep sound when alt+number/letter is pressed on windows --- .lefthook.yml | 5 +---- Wox.UI.Flutter/wox/windows/runner/main.cpp | 12 ++++++++++-- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/.lefthook.yml b/.lefthook.yml index 50fdf165..33d28515 100644 --- a/.lefthook.yml +++ b/.lefthook.yml @@ -2,7 +2,4 @@ pre-commit: commands: go-vet: root: "Wox/" - run: go vet - ui-build: - root: "Wox.UI.React/" - run: pnpm build \ No newline at end of file + run: go vet \ No newline at end of file diff --git a/Wox.UI.Flutter/wox/windows/runner/main.cpp b/Wox.UI.Flutter/wox/windows/runner/main.cpp index 1cc5508e..046beef2 100644 --- a/Wox.UI.Flutter/wox/windows/runner/main.cpp +++ b/Wox.UI.Flutter/wox/windows/runner/main.cpp @@ -45,8 +45,16 @@ int APIENTRY wWinMain(_In_ HINSTANCE instance, _In_opt_ HINSTANCE prev, } window.SetQuitOnClose(true); - ::MSG msg; - while (::GetMessage(&msg, nullptr, 0, 0)) { + ::MSG msg = { }; + while (::GetMessage(&msg, nullptr, 0, 0) > 0) { + // prevent the error/beep sound when alt+number/letter is pressed + if (msg.message == WM_SYSKEYDOWN) { + msg.message = WM_KEYDOWN; + ::TranslateMessage(&msg); + ::DispatchMessage(&msg); + continue; + } + ::TranslateMessage(&msg); ::DispatchMessage(&msg); }