通常,当您使用滚动条在列表内移动光标时,鼠标滚轮会滚动该列表。但是,在OneNote中,当光标肯定在注释列表内(本图中的蓝色区域)时,我只能滚动注释页面本身:
页面是否可以滚动似乎并不重要,当鼠标位于蓝色区域内时,鼠标滚轮不会滚动注释列表。我只能通过使用鼠标左键与滚动条进行交互来滚动它。
It appears to be the issue with Windows 7 (maybe it's the OS, or maybe OneNote version for 7 has this bug). Windows 10 doesn't seem to have this problem at all.
I've been looking for a way to avoid freezes caused by constant checks for the active window and also an overall simpler code solution. Here's what I made:
#ifWinActive ahk_class Framework::CFrame
WheelUp::
ControlGetFocus, control, A
Loop 3
SendMessage, 0x115, 0, 0, %control%, A
Return
#ifWinActive ahk_class Framework::CFrame
WheelDown::
ControlGetFocus, control, A
Loop 3
SendMessage, 0x115, 1, 0, %control%, A
Return
Change the Loop 3
to Loop 5
or however many lines you wish for one movement of the wheel to scroll.
Note: this solution may cause stuttering and occasional freezes on older CPUs or at full CPU load.
我启动了一个AutoIt脚本,该脚本可检测注释列表区域内的光标,并且如果您向上或向下滚动,请在滚动条上单击“向上”和“向下”按钮。这适用于多个OneNote窗口。您无需专注于窗口即可使滚动工作,只需将鼠标悬停在该列表上即可:
#include <AutoItConstants.au3>
#include <MsgBoxConstants.au3>
#include <MouseOnEvent.au3> ; get it from https://www.autoitscript.com/forum/topic/64738-mouseonevent-udf/
#include <WinAPI.au3>
#include <Misc.au3>
_MouseSetOnEvent($MOUSE_WHEELSCROLLUP_EVENT, 'MouseWUp')
_MouseSetOnEvent($MOUSE_WHEELSCROLLDOWN_EVENT, 'MouseWDown')
Opt("WinTitleMatchMode", 2) ; 2 - substring mode
Global $clicks = 3 ; how many items to scroll per scroll, change this to 5, 8, 13, 42 or however fast you wanna scroll
Func MouseWUp($iEvent)
If StringInStr(WinGetTitle($hWin), " - OneNote") Then
; check if cursor is within the notes list and not anywhere else
Local $cur = MouseGetPos()
Local $handle = $hWin ;WinGetHandle("[ACTIVE]")
Local $wpos = WinGetPos($handle) ; returna array of x,y,w,h
Local $cpos = ControlGetPos ($handle, "", "[CLASS:NetUIHWND; INSTANCE:5]")
;MsgBox($MB_SYSTEMMODAL, "title", "win2:" & $wpos[2] & "; win3:" & $wpos[3] & "; cp2:" & $cpos[2] & "; cp3:" & $cpos[3])
If ($cur[0] > $wpos[0] + $wpos[2] - $cpos[2]) And ($cur[0] < $wpos[0] + $wpos[2]) Then
Local $x = $cpos[2] - 2
Local $y = 58
ControlClick($handle, "", "[CLASS:NetUIHWND; INSTANCE:5]", "left", $clicks, $x, $y)
EndIf
EndIf
EndFunc
Func MouseWDown($iEvent)
If StringInStr(WinGetTitle($hWin), " - OneNote") Then
Local $cur = MouseGetPos()
Local $handle = $hWin ;WinGetHandle("[ACTIVE]")
Local $wpos = WinGetPos($handle)
Local $cpos = ControlGetPos ($handle, "", "[CLASS:NetUIHWND; INSTANCE:5]")
If ($cur[0] > $wpos[0] + $wpos[2] - $cpos[2]) And ($cur[0] < $wpos[0] + $wpos[2]) Then
Local $x = $cpos[2] - 2
Local $y = $cpos[3] - 8
ControlClick($handle, "", "[CLASS:NetUIHWND; INSTANCE:5]", "left", $clicks, $x, $y)
EndIf
EndIf
EndFunc
; https://stackoverflow.com/a/11270659
Func _WindowFromPoint($iX,$iY)
Local $stInt64,$aRet,$stPoint=DllStructCreate("long;long")
DllStructSetData($stPoint,1,$iX)
DllStructSetData($stPoint,2,$iY)
$stInt64=DllStructCreate("int64",DllStructGetPtr($stPoint))
$aRet=DllCall("user32.dll","hwnd","WindowFromPoint","int64",DllStructGetData($stInt64,1))
If @error Then Return SetError(2,@error,0)
If $aRet[0]=0 Then Return SetError(3,0,0)
Return $aRet[0]
EndFunc
Local $hControl, $hWin, $hOldWin, $aMousePos
$hOldWin = ""
While True ;Not _IsPressed("1B")
$aMousePos = MouseGetPos()
$hControl=_WindowFromPoint($aMousePos[0],$aMousePos[1])
; Since _WindowFromPoint() can return 'sub' windows, or control handles, we should seek the owner window
$hWin=_WinAPI_GetAncestor($hControl,2)
If $hWin <> $hOldWin Then
;TrayTip("Window Info","Window under mouse = " & WinGetTitle($hWin), 1)
$hOldWin = $hWin
EndIf
Sleep(10)
WEnd
我还没有弄清楚如何防止滚动影响笔记页面本身。如果有人找到了阻止滚动事件从注释列表区域内到达主要注释区域的方法,请分享您的解决方案,以便我们结合使用脚本以达到最佳效果。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句