Close button freezes by injected input in WinUI3?

youki 1,021 Reputation points
2022-10-23T03:11:59.197+00:00

Hi,
The application and anything else freezes, if i click the close button by my own MOUSEEVENTF_LEFTDOWN/UP.

I'm blocking WM_LBUTTONDOWN/ UP by a mouse hook to forward my own injected input. I can click everything (buttons, listview items) except the close button.
If it freezes and i open the task manager, the window closes immediately and the WM_CLOSE gets executed, the same in Debug and Release mode.
I avoid injected input in the hook:

if (MSLLHOOKSTRUCT* pMouseStruct = (MSLLHOOKSTRUCT*)lParam; nCode >= 0 && (pMouseStruct->flags & LLMHF_INJECTED) == 0)  

It seems, as if the close button doesn't accept injected input.

What could be the solution here?

Regards

Windows App SDK
Windows App SDK
A set of Microsoft open-source libraries, frameworks, components, and tools to be used in apps to access Windows platform functionality on many versions of Windows. Previously known as Project Reunion.
780 questions
C++
C++
A high-level, general-purpose programming language, created as an extension of the C programming language, that has object-oriented, generic, and functional features in addition to facilities for low-level memory manipulation.
3,689 questions
0 comments No comments
{count} votes

3 answers

Sort by: Most helpful
  1. youki 1,021 Reputation points
    2022-10-23T11:02:52.777+00:00

    Ok,
    Tested it with WM_LBUTTONDOWN/ UP from a keyboard key and that works. It doesn't work only with injected input from the mouse. I have no problems with any other application on my pc, Win Forms included.

    Don't know, if that is a bug?


  2. youki 1,021 Reputation points
    2022-10-23T17:04:39.7+00:00

    Really don't know what to do:

    https://github.com/microsoft/microsoft-ui-xaml/issues/7858

    Should i change to Electron. As i saw, the memory was pretty low in WinUI, in Electron it's not.

    I could safely ignore that:

    https://github.com/microsoft/microsoft-ui-xaml/issues/7859

    0 comments No comments

  3. Tong Xu - MSFT 2,446 Reputation points Microsoft Vendor
    2022-10-24T02:58:06.843+00:00

    The docunment shows: The mouse_event function synthesizes mouse motion and button clicks.

    It is recommended to use SendInput instead
    https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-sendinput

    WM_LBUTTONDOWN/UP is viable, but be aware that you must get a window to create and deliver messages.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.