That may be difficult to do. You can use Freeze Window to keep changes from taking place while the script is performed, but once the script has completed, changes in "focus" may snap your layout back to the top.
If you have a field, button, portal or tab control at the point where you want to keep the layout "scrolled", you may be able to use the name box in the Inspector's position tab to give it an object name. Then the last step in your script can use go to object to put the focus on that specific layout object. (For a field, you can forgo this and just use go to field to get the same result.)
That isn't likely to perfectly keep the layout unchanged but should keep it "close" to the original posiiton. It also assumes that you can determine the current scroll position of your layout accurately enough to identify a specific layout object to use for this purpose. That isn't always possible.
Thank you, I have tried this and it almost works. Just seems strange not to be able to fix the screen whilst perfoming tasks.