Mouse Wheel scrolls the window right under it

Share your favorite FastKeys commands
User avatar
Posts: 79
Joined: Fri Sep 26, 2014 8:32 pm

Mouse Wheel scrolls the window right under it

PostPosted by gustms » Mon Mar 09, 2015 9:14 pm

Hello there,

searching around, I found a nice program called WizMouse, which would make any window under the mouse scroll with the mouse wheel, even if unfocused. Loved this functionality. But with a bit more searching, I found this great AHK code which does exactly the same thing, in an even better way, and without another extra software installed. Great! So here I share it with anyone else who might be interested in this.

This was the only version I found which doesn't interfere with Volume Mouse Wheel option in FastKeys

Type: Command
Code: Select all
CoordMode Mouse, Screen
WheelTime  = 500
WheelDelta:= 120 << 16
WheelMax  := 4 * WheelDelta


~WheelUp::
~WheelDown::
WinGet, V_CurrentWindowID, ID, A
MouseGetPos,,, V_WinUnderMouseID
WinGetTitle, V_CurrentWinTITLE, ahk_id %V_CurrentWindowID%
WinGetTitle, V_WinUnderMouseTITLE, ahk_id %V_WinUnderMouseID%

If ( ((V_CurrentWinTITLE) = (V_WinUnderMouseTITLE)) AND ((V_CurrentWindowID) = (V_WinUnderMouseID))  )
  Return

   Critical
   If (A_ThisHotKey <> A_PriorHotKey OR A_TimeSincePriorHotkey > WheelTime)
        WCnt = %WheelDelta%
   Else If (WCnt < WheelMax)
        WCnt+=  WheelDelta
   MouseGetPos m_x, m_y
   hw_m_target := DllCall("WindowFromPoint", "int",m_x, "int",m_y)
If (A_ThisHotKey) = "~WheelUp"
  SendMessage 0x20A, WCnt, (m_y<<16)|m_x,,ahk_id %hw_m_target% ; WM_MOUSEWHEEL
Else
  SendMessage 0x20A,-WCnt, (m_y<<16)|m_x,,ahk_id %hw_m_target% ; WM_MOUSEWHEEL
return


Source

User avatar
Posts: 58
Joined: Tue Mar 18, 2014 8:46 am
Location: The Netherlands

Re: Mouse Wheel scrolls the window right under it

PostPosted by Ennovy » Tue Mar 10, 2015 8:07 am

Thank you for sharing this script.

I will try that

Posts: 34
Joined: Sat Aug 02, 2014 7:50 pm

Re: Mouse Wheel scrolls the window right under it

PostPosted by lehmakommionu » Tue Mar 10, 2015 9:52 pm

Thanks for the code. I was using WizMouse as well but it had terrible lag in CAD programs. Also tried multiple AHK scripts but no avail. This works very well except in Windows Explorer where it keeps scrolling both windows.

User avatar
Posts: 79
Joined: Fri Sep 26, 2014 8:32 pm

Re: Mouse Wheel scrolls the window right under it

PostPosted by gustms » Wed Mar 11, 2015 10:33 pm

lehmakommionu wrote:Thanks for the code. I was using WizMouse as well but it had terrible lag in CAD programs. Also tried multiple AHK scripts but no avail. This works very well except in Windows Explorer where it keeps scrolling both windows.


Sorry about that. Tried here, and yes, it has some glitches with Explorer, well noticed. But with Directory Opus, which is what I'm using instead, it is perfect.

Return to User Commands and Scripts

Who is online

Users browsing this forum: No registered users and 0 guests