In a window, say, a folder window or a web browser window, one can pres CTRL + HOME to scroll upmost or CTRL + END to scroll downmost.
But what if I want to scroll to the very middle of the window, how can this be done? With AHk, perhaps?
How to scroll down to the middle of a window?
-
- Posts: 5
- Joined: 07 Jul 2023, 13:27
Re: How to scroll down to the middle of a window?
Why no one replies?
Maybe the vast majority of users work with version 1 instead of with version 2?
Maybe the vast majority of users work with version 1 instead of with version 2?
Re: How to scroll down to the middle of a window?
I would say because this is an unusual request. Not easily answered. It will probably take longer for the right person to see your question and respond (if it is universally possible as all). I think this is relatively easy in a browser using JavaScript, but not sure how challenging it is with an app Window.
-
- Posts: 5
- Joined: 07 Jul 2023, 13:27
Re: How to scroll down to the middle of a window?
I agree.
I have found this way to do it in JavaScript, and it may use as a base for someone here for an AHk solution:
[Mod edit: Changed default AHK code tags to JavaScript-specific Codebox tags.]
I have found this way to do it in JavaScript, and it may use as a base for someone here for an AHk solution:
Code: Select all
// go to downmost part of a webpage to discover its height
window.setTimeout(()=>{
window.scrollTo(0, document.body.scrollHeight);
}, 1000)
window.setTimeout(()=>{
// go back to topmost part of the discovered webpage
window.scrollTo({
top: 100,
left: 100,
behavior: "instant",
});
}, 2000)
window.setTimeout(()=>{
// scroll to the middle of a discovered webpage
window.scrollTo(0, document.documentElement.scrollHeight * 0.50);
}, 3000)
[Mod edit: Changed default AHK code tags to JavaScript-specific Codebox tags.]
Re: How to scroll down to the middle of a window?
@Nkc784sq67xd Have you searched the forum for scrollheight?
I found this right away: viewtopic.php?p=148094#p148094
Should be easily converted to v2, the Acc library for AHK v2 is available here: viewtopic.php?t=107857
Good luck and please post your solution here. Thanks.
I found this right away: viewtopic.php?p=148094#p148094
Should be easily converted to v2, the Acc library for AHK v2 is available here: viewtopic.php?t=107857
Good luck and please post your solution here. Thanks.
Re: How to scroll down to the middle of a window?
It's because this is a difficult problem to solve in a general manner. For older win32 apps you could use SetScrollPos and for a lot of applications you can use the previously mentioned Acc method (it should also work in apps where SetScrollPos works). However, some applications can't be scrolled programmatically, for example Chrome. In that case you would need to use some kind of image-based approach to detect where the scroll thumb is and use Send/ControlSend to scroll. Alternatively inject Javascript through the URL bar, or use Chrome.ahk to directly automate the browser.Nkc784sq67xd wrote: ↑03 Dec 2023, 15:43Why no one replies?
Maybe the vast majority of users work with version 1 instead of with version 2?
As you can see, creating a working reliable solution for ALL applications is near impossible. Perhaps we could help if you specify which application you want to automate?