Mouse Wheel scrolls the window right under it

Share your favorite FastKeys commands
Post Reply
User avatar
gustms
Posts: 133
Joined: Sep 26th, ’14, 21:32
Location: USA

Post by gustms » Mar 9th, ’15, 21:14

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
Ennovy
Posts: 70
Joined: Mar 18th, ’14, 08:46

Post by Ennovy » Mar 10th, ’15, 08:07

Thank you for sharing this script.

I will try that
lehmakommionu
Posts: 34
Joined: Aug 2nd, ’14, 20:50

Post by lehmakommionu » Mar 10th, ’15, 21:52

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
gustms
Posts: 133
Joined: Sep 26th, ’14, 21:32
Location: USA

Post by gustms » Mar 11th, ’15, 22:33

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.
Post Reply