I have already tried using a few articles at CodeProgect and other places about universal hooks but I have not been able figure out how to get anything to the way I want it to. I want to create a hotkey, (mousewheel + shift), that works even when my app does not have focus. All of the articles that I have tried (I say tried because I had varying degrees of success) to use so far have had separate hooks for keys and mouse. Is there any way that I can do what I want?

1 answers
TBH, using the mouse wheel as part of a hotkey combination is not a great idea because (unlike the mouse buttons) it doesn't have a virtual key code and some users of your program with older mice may not even have one!
If you nevertheless want to use it, then all I can suggest is that you use a global mouse hook to trap mouse wheel movement in isolation and simultaneously test the state of the shift keys.
There is a managed property, Control.ModifierKeys which can be used to test the state of the modifier keys but it may not work when your application doesn't have the focus.
If that's the case, then you could use the API function, GetKeyState() which should work whether your application has the focus or not.
answered 2 years ago by:
17279
51
I ended up using this universal mouse and keyboard hook library from codeprogect: http://www.codeproject.com/KB/system/globalmousekeyboardlib.aspx Then I created a public static bool shiftisdown which is changed accordingly at the keyup and keydown events. The my method in the mouse wheel event then checks to see if it is true or not.