-
October 20th, 2020, 05:18 PM
#1
SetWindowsHookEx stops receiving WH_MOUSE_LL notifications after focus lost
Hi, I found this forum by stumbling onto the similar question here.
The difference is, that in my case I have a SetWindowsHookEx in a simple c++ program, not a dll. The program creates an SDL2 window. But when that window loses focus, the SetWindowsHookEx stops receiving WH_MOUSE_LL messages.
I tried to include the code snippet suggested by Igor Vartanov in the link above, but it did not help in my case.
Any suggestion on how to make SetWindowsHookEx continue receiving WH_MOUSE_LL messages after focus of the SDL2 window is lost?
-
October 20th, 2020, 08:44 PM
#2
Re: SetWindowsHookEx stops receiving WH_MOUSE_LL notifications after focus lost
Your hook doesn't stop working per se, it's just that Windows quits sending mouse messages to your window when it's lost focus.
You have at least two options:
1) keep your app in focus
2) use a global hook
-
December 4th, 2020, 06:05 AM
#3
Re: SetWindowsHookEx stops receiving WH_MOUSE_LL notifications after focus lost
i have the same issue but where to find global hook
-
December 4th, 2020, 06:15 AM
#4
Re: SetWindowsHookEx stops receiving WH_MOUSE_LL notifications after focus lost
Re global hooks. See https://docs.microsoft.com/en-us/win...sg/using-hooks
The global hook has to be in a separate dll.
All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!
C++23 Compiler: Microsoft VS2022 (17.6.5)
-
December 7th, 2020, 08:53 AM
#5
Re: SetWindowsHookEx stops receiving WH_MOUSE_LL notifications after focus lost
Just in case if more people encounter this problem -- in my case the issue could be resolved as follows:
Windows stops sending updates to the hook (normal one, not global) if the focus is lost to a window that is running with administrator permissions while our program with the hook is running with a regular user permissions. The solution in that case was to simply start our program with administrator permissions as well, then updates are sent to the hook even after focus is lost.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|