HoverScroll() is a function for scrolling any control directly under the mouse pointer, regardless of whether it has focus or not. This function started off as FocuslessScroll() somewhere in the middle of this thread, but I've decided to move it to a thread of its own to make it easier to find. Recently I have reviewed, enhanced and simplified the code and I'd like to share it.
Download: HoverScroll v1.04.zip (includes ready-to-use example script demonstrating vertical scroll, horizontal scroll and zoom)
For best results configure your scrollwheel to scroll one line per step/notch in Windows > Control Panel > Mouse > Wheel > Vertical Scrolling:
The simplest way to use HoverScroll() is as follows:
;Scroll 1 line per notch. ;The first parameter tells the function how many lines to scroll per notch of the scroll wheel. A negative value reverses scroll direction. WheelUp::HoverScroll(1) ;scroll up WheelDown::HoverScroll(-1) ;scroll down
HoverScroll() accepts other parameters to fine-tune it's behaviour. All parameters are optional, and HoverScroll() assumes default values if any parameters are omitted. Please see HoverScroll.ahk for details.
Horizontal scroll:
;Horizontal scroll ;Make the second parameter = 1 for vertical scrolling, = 0 (or any other value) for horizontal scrolling ;If the second argument is omitted, HoverScroll() assumes vertical scrolling ;Vertical WheelUp::HoverScroll(1, 1) ;This is equivalent to HoverScroll(1) WheelDown::HoverScroll(-1, 1) ;This is equivalent to HoverScroll(-1) ;Horizontal !WheelUp::HoverScroll(1, 0) !WheelDown::HoverScroll(-1, 0)
Focusless zoom:
;Focusless zoom ;If the third paramter is equal to 1, HoverScroll() will send Ctrl-Scroll, which is used for zooming in many applications. ;Any hotkey can be used to call HoverScroll(). This example enables us to zoom by means of either the traditional Ctrl-Scroll ;or by holding down XButton1 while scrolling. XButton1 & WheelUp:: ^WheelUp:: HoverScroll(1,,1) Return XButton1 & WheelDown:: ^WheelDown:: HoverScroll(-1,,1) Return ;NOTE: Some applications (e.g. MS Word, MS Visio) won't zoom unless you use Ctrl as the modifier. ;NOTE: Although in theory we could zoom at more than 1 line per notch, it is recommended you use a value of 1 because some ;applications will not respond predictably to other values. Again, you are free to experiment and specify per-application values.
Other modifiers:
msdn.microsoft.com/en-us/library/ms645617%28v=vs.85%29.aspx
HoverScroll() sends the WM_MOUSEWHEEL and WM_MOUSEHWHEEL messages to do its job. These messages only support sending of Ctrl and Shift, and to the best of my knowledge there is no easy way to overcome this limitation, maybe someone can chime in and prove me wrong.
;Third parameter = 1 sends Ctrl ;Forth parameter = 1 sends Shift ;Shift-Scroll HoverScroll(1,,,1) HoverScroll(-1) ;Shift-Ctrl combined HoverScroll(1,,1,1) HoverScroll(-1,,1,1)
Read my next post below for a description of scrollwheel acceleration using the supplied LinesPerNotch() functions.