Search code examples
javahookmousejna

How to distinguish between scrolling up or scrolling down when using jna to listen for mouse events


This is the code that uses jna to listen for mouse events.code detail.

I found that the scrolling code for the scroll wheel is 522, but I can't distinguish between up and down scrolling. Can I have a way to distinguish between sliding up and down the scroll wheel?


Solution

  • In a Windows mouse hook the WPARAM will alert you to a scroll wheel event, and the LPARAM, what is called MOUSEHOOKSTRUCT info in the code link you've posted, will give you the details about the event, including here the wheel delta.

    Pertinent MSDN links that reference this: