I have edited my earlier script to use WM_VSCROLL and not need the Acc library (commenting out the original Acc lines).
==================================================
I'm not sure why you're getting the opposite result, you could try and use ToolTips or some other means, to work out what's happening.
However, I did see something a bit like the behaviour you described: if I had the treeview focused, and used WheelUp/WheelDown while the cursor was over the file list, the file list scrolled, if I then moved over a nearby control, that was not the file pane control or treeview, and then used WheelUp/WheelDown, the treeview (as it was still the focused control) would scroll. So although that was the behaviour that was expected, it's perhaps undesirable.
The script could store the last control that it scrolled, in a variable, and scroll that control whenever WheelUp/WheelDown is used, that variable's value would be changed whenever it detects one of the 2 controls it's looking for, under the cursor. Alternatively the ControlFocus approach could be a good option ...
==================================================
I have rewritten the script from earlier using ControlFocus. You might like to have a go at editing the original script to try and recreate this script yourself before checking my script.
Code: Select all
;using ControlFocus to set the control focus
#IfWinActive, ahk_class CabinetWClass
$WheelDown:: ;Explorer window - scroll pane under cursor (tested on Windows 7)
$WheelUp:: ;Explorer window - scroll pane under cursor (tested on Windows 7)
#IfWinActive, ahk_class ExploreWClass
$WheelDown:: ;Explorer window - scroll pane under cursor (tested on Windows 7)
$WheelUp:: ;Explorer window - scroll pane under cursor (tested on Windows 7)
ControlGetFocus, vCtlClassNN1, A
MouseGetPos,,,, vCtlClassNN2
if ((vCtlClassNN1 = "SysTreeView321") && (vCtlClassNN2 = "DirectUIHWND3"))
|| ((vCtlClassNN2 = "SysTreeView321") && (vCtlClassNN1 = "DirectUIHWND3"))
ControlFocus, % vCtlClassNN2, A
SendInput, % InStr(A_ThisHotkey, "Up") ? "{WheelUp}" : "{WheelDown}"
ToolTip % "foc: " vCtlClassNN1 "`r`n" "und: " vCtlClassNN2
return
#IfWinActive
Here is a slight variant, what it does is: it doesn't actually consume the WheelUp/WheelDown presses, but it lets them take place, and checks/sets the control at the same time:
Code: Select all
;using ControlFocus to set the control focus
#IfWinActive, ahk_class CabinetWClass
~WheelDown:: ;Explorer window - scroll pane under cursor (tested on Windows 7)
~WheelUp:: ;Explorer window - scroll pane under cursor (tested on Windows 7)
#IfWinActive, ahk_class ExploreWClass
~WheelDown:: ;Explorer window - scroll pane under cursor (tested on Windows 7)
~WheelUp:: ;Explorer window - scroll pane under cursor (tested on Windows 7)
ControlGetFocus, vCtlClassNN1, A
MouseGetPos,,,, vCtlClassNN2
if ((vCtlClassNN1 = "SysTreeView321") && (vCtlClassNN2 = "DirectUIHWND3"))
|| ((vCtlClassNN2 = "SysTreeView321") && (vCtlClassNN1 = "DirectUIHWND3"))
ControlFocus, % vCtlClassNN2, A
ToolTip % "foc: " vCtlClassNN1 "`r`n" "und: " vCtlClassNN2
return
#IfWinActive