WM_MOUSEMOVE / wParam doesn't contain key state, only when any mouse button is pressed

274 Views Asked by At

I use a WS_EX_LAYERED window and receive a WM_MOUSEMOVE message when the mouse moves over non-transparent areas. So far so good.

  • When I press and hold SHIFT or CTRL and move the mouse, WM_MOUSEMOVE/wParam doesn't indicate the key state.

  • When I press and hold SHIFT or CTRL and ANY mouse buttons while moving the mouse, WM_MOUSEMOVE/wParam does indicate the key state.

  • When I click into the window (assuming to set focus) and hold SHIFT or CTRL, again, WM_MOUSEMOVE / wParam doesn't indicate the key state.

Any idea what's up here? I have the suspicion that it has something to do with the active focus state of the window.

1

There are 1 best solutions below

1
On

I believe that if you need to get input when your window isn't in focus you would have to use this:

https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-setwindowshookexa?redirectedfrom=MSDN

other than that, if you're just moving the mouse you can assume that the key state hasn't changed, can't you?