Sign in to follow this  
Followers 0
runsnake

How to control NOTEPAD scrolling accurately?

3 posts in this topic

Following code, only Track box scrolled, But the contents in the NOTEPAD won't scroll, why ?

#include <GUIScrollBars.au3>
#include <ScrollBarConstants.au3>
Run("Notepad")
Sleep(200)
$hWin = WinGetHandle("[CLASS:Notepad]")
$hCtrl = ControlGetHandle("[CLASS:Notepad]", "", "Edit1")
WinActivate($hCtrl)
For $i = 1 To 40
ControlSend($hWin, "", "Edit1", $i & @LF)
Next
ControlSend($hWin, "", "Edit1", "{PGUP}")
$Max = _GUIScrollBars_GetScrollInfoMax($hCtrl, $SB_VERT)
$TrackPos = _GUIScrollBars_GetScrollInfoTrackPos($hCtrl, $SB_VERT)
$PageSize = _GUIScrollBars_GetScrollInfoPage($hCtrl, $SB_VERT)
For $i = $TrackPos To $Max - $PageSize + 1 Step 1
SetScrollPos($hCtrl, $SB_VERT, $i)
;_GUIScrollBars_ScrollWindow($hWin, 0, 1)
Sleep(100)
Next
Func SetScrollPos($Hwnd, $nBar, $nPos, $bRedraw = True)
$PrePos = DllCall("User32.dll", "int", "SetScrollPos", "HWND", $Hwnd, "int", $nBar, "int", $nPos, "int", $bRedraw)
If @error Then Return ""
Return $PrePos[0]
EndFunc

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

nevermind.

Edited by javasqlrpg

Share this post


Link to post
Share on other sites

try the following code

#include <GUIScrollBars.au3>
#include <ScrollBarConstants.au3>
#include <SendMessage.au3>
#include <WindowsConstants.au3>
Run("Notepad")
Sleep(200)
$hWin = WinGetHandle("[CLASS:Notepad]")
$hCtrl = ControlGetHandle("[CLASS:Notepad]", "", "Edit1")
WinActivate($hCtrl)
For $i = 1 To 40
ControlSend($hWin, "", "Edit1", $i & @LF)
Next
ControlSend($hWin, "", "Edit1", "{PGUP}")
Sleep(500)
$Max = _GUIScrollBars_GetScrollInfoMax($hCtrl, $SB_VERT)
$TrackPos = _GUIScrollBars_GetScrollInfoTrackPos($hCtrl, $SB_VERT)
$PageSize = _GUIScrollBars_GetScrollInfoPage($hCtrl, $SB_VERT)
For $i = $TrackPos To $Max - $PageSize + 1 Step 1
_SendMessage($hCtrl, $WM_VSCROLL, $SB_LINEDOWN, 0)
Sleep(100)
Next

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0