littlebigman Posted 4 hours ago Posted 4 hours ago Hello, I need to write a script to download the list of pages open in Chrome, display a multiselect listbox, and loop and download the selected pages. Is there a better way than this? Thank you. expandcollapse popup#include <Array.au3> #include <ClipBoard.au3> #include <MsgBoxConstants.au3> #include <StringConstants.au3> #include <Constants.au3> #include <WindowsConstants.au3> #include <File.au3> #include <String.au3> Func _WinWaitActivate($title,$text,$timeout=5) Local $result = False $result = WinWait($title,$text,$timeout) if $result = False Then Exit MsgBox($MB_ICONERROR,"Bad...","Window not displayed") If Not WinActive($title,$text) Then WinActivate($title,$text) WinWaitActive($title,$text,$timeout) EndFunc Opt("WinTitleMatchMode", 2) ;1=start (default), 2=subStr, 3=exact, 4=advanced (deprecated), -1 to -4=Nocase ;Get list of open tabs _WinWaitActivate("[TITLE: - Google Chrome;CLASS:Chrome_WidgetWin_1]","") Sleep(500) Send("^+{A}") ; Send Ctrl + Shift + A to open tab search Sleep(150) Send("As the mother of a student in Paris") ; Type the name of the tab Sleep(150) Send("{ENTER}") ; Press Enter to select the tab ;Loop through open tabs until back to square one Local $aURLs[0] Local $sFirstURL = "" Local $sCurrentURL = "" While True ; Highlight address bar and copy text Send("!d") ; Alt + D (Selects the URL bar) Sleep(150) Send("^c") ; Ctrl + C (Copies to clipboard) Sleep(150) $sCurrentURL = ClipGet() ; If this is the very first tab checked, store it as the anchor If $sFirstURL == "" Then $sFirstURL = $sCurrentURL ElseIf $sCurrentURL == $sFirstURL Then ; If the current URL matches the first URL, we've looped back to the start ExitLoop EndIf ; Add the unique URL to our array _ArrayAdd($aURLs, $sCurrentURL) ; Switch to the next tab Send("^{TAB}") ; Ctrl + Tab Sleep(200) WEnd ;TODO display multiselect listbox and grab each selected page ;Display the collected URLs _ArrayDisplay($aURLs, "Collected Chrome URLs")
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