ranphx Posted May 11, 2022 Share Posted May 11, 2022 Hello, I have the following problem I need to write a script that opens different sites in the tabbar of Chrome, scrolls down each site and switches everytime, it reached the bottom of a page. So far I managed it to open the sites and switch between them but my script right now is just depending on a specific time to switch which is unfortunate because the sites are not the same length So there is a difference in the waiting time between the sites while it still tries to scroll down. Because I'm new to autoit I don't know for sure if there is a function that could tell me if Chrome reached the bottom of a site like I found with getScrollPos in C++ . Link to comment Share on other sites More sharing options...
Developers Jos Posted May 11, 2022 Developers Share Posted May 11, 2022 Moved to the appropriate AutoIt General Help and Support forum, as the Developer General Discussion forum very clearly states: Quote General development and scripting discussions. Do not create AutoIt-related topics here, use the AutoIt General Help and Support or AutoIt Technical Discussion forums. Moderation Team SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
Nine Posted May 11, 2022 Share Posted May 11, 2022 One way would be to use WebDriver and execute JavaScript to get the height of the document and compare it with the position of the scroll bar (or something similar) . That seems to work quite well : Local $JS_ScrollTop = Json_Decode(_WD_ExecuteScript($sSession, 'return document.documentElement.scrollTop;')) Local $JS_Scr_Height = Json_Decode(_WD_ExecuteScript($sSession, "return screen.height;")) Local $JS_Doc_Height = Json_Decode(_WD_ExecuteScript($sSession, "return document.body.scrollHeight;")) Local $JS_Scr_InnerHeight = Json_Decode(_WD_ExecuteScript($sSession, "return window.innerHeight;")) ConsoleWrite("ScrollTop " & Json_Get($JS_ScrollTop, "[value]") & @CRLF & _ "Scr_Height " & Json_Get($JS_Scr_Height, "[value]") & @CRLF & _ "Doc_Height " & Json_Get($JS_Doc_Height, "[value]") & @CRLF & _ "Scr_InnerHeight " & Json_Get($JS_Scr_InnerHeight, "[value]") & @CRLF) Local $iScrollTop = Number(Json_Get($JS_ScrollTop, "[value]")) Local $iDocHeight = Number(Json_Get($JS_Doc_Height, "[value]")) Local $iInnerHeight = Number(Json_Get($JS_Scr_InnerHeight, "[value]")) If $iScrollTop + $iInnerHeight >= $iDocHeight Then MsgBox($MB_SYSTEMMODAL, "You are", "at the bottom") “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
Danp2 Posted May 11, 2022 Share Posted May 11, 2022 @NineYou could use an array to eliminate the repeated calls to _WD_ExecuteScript -- $sScript = "return new Array(document.documentElement.scrollTop, screen.height, document.body.scrollHeight, window.innerHeight);" $aResults = _WD_ExecuteScript($sSession, $sScript, $_WD_EmptyDict, Default, $_WD_JSON_Value) I'm wondering if this could be done with one of the _GuiScrollBars functions. mLipok 1 Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
Nine Posted May 11, 2022 Share Posted May 11, 2022 30 minutes ago, Danp2 said: I'm wondering if this could be done with one of the _GuiScrollBars functions. I tried it but it doesn't work. I do believe that the scroll bars are not standard Window elements (like pretty much everything else in Chrome). 33 minutes ago, Danp2 said: You could use an array to eliminate the repeated calls Thanks for the tip. As you can see, I am not a JS wizard... Danp2 1 “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
ranphx Posted May 18, 2022 Author Share Posted May 18, 2022 Is there an option without WebDriver, cause I need it for work but they seem to be hesitant to let me install it. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now