View Single Post
Old 04-18-2019, 02:22 PM   #2596
juliansader
Human being with feelings
 
Join Date: Jul 2009
Posts: 2,659
Default

Quote:
Originally Posted by nofish View Post
You could try:
JS_Window_SetScrollPos() available in the js_ReaScriptAPI extension.
I haven't tested it much, but this might work:
Code:
trackview = reaper.JS_Window_FindChildByID(reaper.GetMainHwnd(), 1000)
infoOK, scrollPos, pageSize, min, max, trackPos = reaper.JS_Window_GetScrollInfo(trackview, "HORZ")
cursorTime = reaper.GetCursorPositionEx(0) -- Always counted from start of project, ignores "Project start time"
zoom = reaper.GetHZoomLevel() -- returns pixels/second
cursorPixels = cursorTime*zoom
newScrollPos = math.floor(cursorPixels - pageSize*0.9)
reaper.JS_Window_SetScrollPos(trackview, "HORZ", newScrollPos)
juliansader is offline   Reply With Quote