views:

22

answers:

1

I recently stumbled upon a global hotkey class (This one), it works very well and was just what i needed.

But i ran into an issue with it, for some reason it doesn't work with the mouse buttons XButton1 and XButton2.

So i would like to ask, if there's any way to make it work, or if there's a logical explanation as of why it won't work.

Oh, and i don't think there already is a global hotkey bound to the XButtons.

Thanks in advance
- Casper

A: 

I don't see any code for that class. But it almost certainly uses the RegisterHotKey() API function. Which works for keyboard keys, not mouse buttons. To globally trap mouse button events you need to use SetWindowsHookEx, using a WH_MOUSE_LL hook. That googles really well, you'll find many examples.

Hans Passant
Thank you so much, i found a great example: http://www.codeproject.com/KB/cs/globalhook.aspx althought i had to edit it to make it work with XButtons, but apparently that was quite easy.
Casper