Search code examples
c++qtwinapimessagemouseclick-event

Qt WinEvent - Never raised


I'm trying to get a mouse click event in Qt, this mouse click must be global, and must be received even if the mouse isn't over my app window, I saw in these links:

Receive WM_COPYDATA messages in a Qt app

http://developer.qt.nokia.com/forums/viewthread/8103

That I can get a message from Windows reimplementing the WinEvent. I have tried this and when debuging this event is never raised. Have I missed something?

here's a sample of my code:

bool WindowsUtil::winEvent( MSG * message, long * result )  {
  if (message->message == WM_LBUTTONDOWN) {//never got here at all
    *result = 0;
    return true;
  }

  // give the event to qt
  return false;
} 

Solution

  • Finally got it.

    I used SetWindowsHookEx on the initialization with WH_MOUSE_LL as a paramenter for low level messages. So, at the end, no Qt code was needed for getting mouse events.