small refactoring

pull/2/head
Yuriy 2 years ago
parent 1a96cb6e74
commit e85945c197

1
.gitignore vendored

@ -11,3 +11,4 @@ body.txt
**ConnectToActiveChromeTab.ahk **ConnectToActiveChromeTab.ahk
Freedomain Social Media Poster*.exe Freedomain Social Media Poster*.exe
Compile Scripts to EXE.ahk Compile Scripts to EXE.ahk
Freedomain Video Uploader.exe

@ -34,13 +34,6 @@ FullScriptName := ScriptName . " - " . ScriptVersion
; Included Files
#include %A_ScriptDir%\Lib\StdOutToVar.ahk ; used for chrome debugging mode connection
#Include C:\Users\%A_UserName%\Syncthing\Git\Freedomain-Social-Media-Poster\Lib\SharedFunctions.ahk ; @todo, move this to a git submodule
#Include %A_ScriptDir%\Lib\JSON.ahk
#Include %A_ScriptDir%\Lib\ChromeAutomationFunctions.ahk
;---ToDo--- ;---ToDo---
;------------------------------------------------ ;------------------------------------------------
; @todo: Update Locals Share link grabbing ; @todo: Update Locals Share link grabbing
@ -5008,6 +5001,18 @@ Return
; -------------------------------Functions------------------------------- ; -------------------------------Functions-------------------------------
; Included Files
#include %A_ScriptDir%\Lib\StdOutToVar.ahk ; used for chrome debugging mode connection
#Include %A_ScriptDir%\Lib\SharedFunctions.ahk
#Include %A_ScriptDir%\Lib\JSON.ahk
#Include %A_ScriptDir%\Lib\ChromeAutomationFunctions.ahk
#Include %A_ScriptDir%\Lib\\RunCMD.ahk
; #Include %A_ScriptDir%\Lib\ChromeAutomationFunctions.ahk
CheckLBRYProcess(){ CheckLBRYProcess(){
; Check if LBRY Process exists ; Check if LBRY Process exists
Process, Exist,LBRY.exe Process, Exist,LBRY.exe

@ -15,8 +15,6 @@ global CurrentTabURL
; #Include %A_ScriptDir%\RunCMD.ahk ; #Include %A_ScriptDir%\RunCMD.ahk
DevModeMsgBox(Message){ DevModeMsgBox(Message){
if(!DevMode) if(!DevMode)
return return
@ -29,60 +27,67 @@ DevModeMsgBox(Message){
CheckForUpdates(){ CheckForUpdates(){
; msgbox, checking for updates ; msgbox, checking for updates
Message = Checking For Updates Message = Checking For Updates
SaveOrPostProgress(Message,PostType:="ErrorLoggingTextFile") SaveOrPostProgress(Message,PostType:="Tooltip,ErrorLoggingTextFile")
data := URLDownloadToVar(GitReleasesAPIURL)
; Msgbox % "data: " data
parsed := JSON.Load(data) ; Msgbox % "FreedomScriptsChangelogURL: " FreedomScriptsChangelogURL
; Msgbox % "ChangelogIniFilepath: " ChangelogIniFilepath
; Msgbox % "ScriptSettingsSectio: " ScriptSettingsSection
; Msgbox % "SettingsIniFilepath: " SettingsIniFilepath
UpdateVersionNumber := parsed.1.name UrlDownloadToFile, %FreedomScriptsChangelogURL%, %ChangelogIniFilepath%
if(ErrorLevel){
Message = Failed to Download Changelog
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging")
Return
}
if(ScriptVersion = UpdateVersionNumber OR ScriptVersion > UpdateVersionNumber){ IniRead, UpdateVersion, %ChangelogIniFilepath%, %ScriptSettingsSection%, ScriptVersion, %A_Space%
if(UpdateVersion = ""){
ToolTip ToolTip
return ; MsgBox, update version is blank.
Return
} }
else, {
UpdateAvailable := 1
if(ScriptVersion != UpdateVersion){
; msgbox, update found! ; msgbox, update found!
Message = Program Update Found Message = Script Update Found
SaveOrPostProgress(Message:=Message,PostType:="ErrorLoggingTextFile") SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile")
; IniWrite, 1, %SettingsIniFilepath%, %ScriptSettingsSection%, UpdateAvailable IniWrite, 1, %SettingsIniFilepath%, %ScriptSettingsSection%, UpdateAvailable
; ToolTip
return
}
GuiControl,, UpdateAvailable, Update Available - Click to View
}
else, {
Message = No Updates Found
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile")
IniWrite, 0, %SettingsIniFilepath%, %ScriptSettingsSection%, UpdateAvailable
}
ToolTip
} }
UpdateScript(){
data := URLDownloadToVar(GitReleasesAPIURL)
parsed := JSON.Load(data)
UpdateVersionNumber := parsed.1.name UpdateScript(){
ChangeLog := parsed.1.body ; Msgbox % "ChangelogIniFilepath: " ChangelogIniFilepath
exename := parsed.1.assets.1.name ; Msgbox % "ScriptSettingsSection: " ScriptSettingsSection
exeURL := parsed.1.assets.1.browser_download_url
; Msgbox % "UpdateVersionNumber: " UpdateVersionNumber IniRead, Changelog, %ChangelogIniFilepath%, %ScriptSettingsSection%, Changelog, %A_Space%
; msgbox, Version: %Version% Changelog := StrReplace(Changelog, "--", "`n-")
; Msgbox % "ChangeLog: " ChangeLog
; Msgbox % "exeURL: " exeURL
; Msgbox % "exename: " exename
ExeName := StrReplace(exename, ".exe", "") IniRead, UpdateVersion, %ChangelogIniFilepath%, %ScriptSettingsSection%, ScriptVersion, %A_Space%
UpdateExeName = %exename% %UpdateVersionNumber%.exe
UpdateExeFilepath = %A_ScriptDir%\%UpdateExeName%
if(ScriptVersion = UpdateVersionNumber){ if(ScriptVersion = UpdateVersion){
; IniWrite, 0, %SettingsIniFilepath%, %ScriptSettingsSection%, UpdateAvailable IniWrite, 0, %SettingsIniFilepath%, %ScriptSettingsSection%, UpdateAvailable
MsgBox, You are Up-To-Date MsgBox, You are Up-To-Date
; IniRead, UpdateAvailable, %SettingsIniFilepath%, %ScriptSettingsSection%, UpdateAvailable, 0 ; IniRead, UpdateAvailable, %SettingsIniFilepath%, %ScriptSettingsSection%, UpdateAvailable, 0
return return
} }
Changelog = %ScriptVersion% --> %UpdateVersionNumber%`n%Changelog% Changelog = %ScriptVersion% -> %UpdateVersion%`n`n-%Changelog%
OnMessage(0x44, "OnMsgBoxUpdateAvailable") OnMessage(0x44, "OnMsgBoxUpdateAvailable")
MsgBox 0x44, Update Available, %Changelog% MsgBox 0x44, Update Available, %Changelog%
@ -90,22 +95,19 @@ UpdateScript(){
IfMsgBox Yes, { IfMsgBox Yes, {
Return Return
} } Else IfMsgBox No, {
Else IfMsgBox No, { run, "%FreedomainProgramUpdaterFilepath%" "%ScriptSettingsSection%"
SaveOrPostProgress(Message:="Downloading Update",PostType:="Tooltip,ErrorLoggingTextFile") ; Return
; Msgbox, downloading to: %A_ScriptDir%\%UpdateExeName%
UrlDownloadToFile, %exeURL%, %UpdateExeFilepath%
run, "%UpdateExeFilepath%" "%A_ScriptFullPath%"
ExitApp ExitApp
} }
return return
} }
; -------------------------------SaveOrPostProgress------------------------------- ; -------------------------------SaveOrPostProgress-------------------------------
; PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging,DiscordVideos" ; PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging,DiscordVideos"
SaveOrPostProgress(Message:="",PostType:=""){ SaveOrPostProgress(Message:="",PostType:=""){
MessageBU := Message MessageBU := Message
; Msgbox % "PostType: " PostType ; Msgbox % "PostType: " PostType
@ -137,9 +139,9 @@ SaveOrPostProgress(Message:="",PostType:=""){
} }
; -------------------------------/SaveOrPostProgress------------------------------- ; -------------------------------/SaveOrPostProgress-------------------------------
TakeScreenshotOfPage(SaveFilepath := ""){ TakeScreenshotOfPage(SaveFilepath := ""){
if(!ScreenshotResult) if(!ScreenshotResult)
return return
@ -154,9 +156,9 @@ TakeScreenshotOfPage(SaveFilepath := ""){
; if(!FileExist(SaveFilepath)) ; if(!FileExist(SaveFilepath))
FileCreateDir, %SaveFilepath% FileCreateDir, %SaveFilepath%
if(!TakeScreenshotsOfErrors) /* if(!TakeScreenshotsOfErrors)
Return Return
*/
; Take a screenshot of the page and save it. ; Take a screenshot of the page and save it.
FormatTime, TodayDate , YYYYMMDDHH24MISS, yyyyMMdd_hhmmss FormatTime, TodayDate , YYYYMMDDHH24MISS, yyyyMMdd_hhmmss
@ -788,7 +790,6 @@ CreateArrayOfTabs() {
DriverURLArray := [] DriverURLArray := []
try TotalTabsFound := Driver.Windows.Count try TotalTabsFound := Driver.Windows.Count
; DevModeMsgBox(TotalTabsFound)
; if only 1 tab exists, grab info, push to array and exit early ; if only 1 tab exists, grab info, push to array and exit early
if(TotalTabsFound = 1){ if(TotalTabsFound = 1){
@ -814,7 +815,7 @@ CreateArrayOfTabs() {
StartTime := A_TickCount StartTime := A_TickCount
Loop, { Loop, {
Message = Creating an Array of All Chrome Tabs`nCurrent Loop: %A_index%/%TotalTabsFound%`nSometimes might get stuck for a short while if there is something loading in active tab Message = Creating an Array of All Chrome Tabs`nCurrent Loop: %A_index%/%TotalTabsFound% (Cannot loop through unloaded tabs)`nSometimes might get stuck for a short while if there is something loading in active tab
TooltipThis(Message) TooltipThis(Message)
; SaveOrPostProgress(Message:=URL,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar") ; SaveOrPostProgress(Message:=URL,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar")
@ -852,9 +853,6 @@ CreateArrayOfTabs() {
try Title := Driver.Title try Title := Driver.Title
try URL := Driver.URL try URL := Driver.URL
; DevModeMsgBox(Title)
; DevModeMsgBox(URL)
; TimeToGrabCurrentTab := A_TickCount - StartTime ; TimeToGrabCurrentTab := A_TickCount - StartTime
; Msgbox % "TimeToGrabCurrentTab: " TimeToGrabCurrentTab ; Msgbox % "TimeToGrabCurrentTab: " TimeToGrabCurrentTab
; VAR := HasVal(DriverURLArray, STRINGVAR) ; returns position of value in array ; VAR := HasVal(DriverURLArray, STRINGVAR) ; returns position of value in array
@ -896,13 +894,11 @@ if(TotalTabsFound = 1){
; Msgbox % "A_index: " A_index ; Msgbox % "A_index: " A_index
; DevModeMsgBox("breaking early on loop 1?") ; DevModeMsgBox("breaking early on loop 1?")
break break
; if there is only 1 tab, then break out of loop and don't bother looping through same tab } ; if there is only 1 tab, then break out of loop and don't bother looping through same tab
}
*/ */
try driver.SwitchToNextWindow ;Focuses Selenium on the newly opened/next window. try driver.SwitchToNextWindow ;Focuses Selenium on the newly opened/next window.
; end of loop } ; end of loop
}
; Iterate from 1 to the end of the array: ; Iterate from 1 to the end of the array:
Loop % DriverURLArray.Length() Loop % DriverURLArray.Length()
@ -919,8 +915,7 @@ if(TotalTabsFound = 1){
SaveOrPostProgress(Message:=Message,PostType:="ErrorLoggingTextFile,DiscordErrorLogging") SaveOrPostProgress(Message:=Message,PostType:="ErrorLoggingTextFile,DiscordErrorLogging")
; DevModeMsgBox(Message) ; DevModeMsgBox(Message)
return return
; / END OF FUNC } ; /FUNC
}
InputFilePathIntoOpenWindow(Filepath){ InputFilePathIntoOpenWindow(Filepath){
; Msgbox % "Filepath: " Filepath ; Msgbox % "Filepath: " Filepath
@ -948,72 +943,32 @@ if(TotalTabsFound = 1){
ToolTip, ToolTip,
} }
CheckCurrentTabForCurrentSite(){
try CurrentTabURL := driver.url
if(!InStr(CurrentTabURL, CurrentSite)){
Message = Chromedriver failed to switch to %CurrentSite%. Please see errorlog for website it got stuck on.
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging")
return "Failed"
}
; msgbox % InStr(CurrentTabURL,CurrentSite)
}
; -------------------------------NavigateFromBaseURLTo------------------------------- ; -------------------------------NavigateFromBaseURLTo-------------------------------
NavigateFromBaseURLTo(URL, TabTitle := ""){ NavigateFromBaseURLTo(URL,PageTitle := "New Tab"){
if(!DriverStatus){ ; if not connected to selenium chrome, then re-connect if(!DriverStatus){ ; if not connected to selenium chrome, then re-connect
Status := CheckSeleniumDriver() Status := CheckSeleniumDriver()
if(Status) if(Status)
Return "Failed" Return "Failed"
CreateArrayOfTabs() ; store all open tabs to memory for later usage CreateArrayOfTabs()
} }
if(ReuseTabs){ ; pull out base of URL and check if it's within the array of tabs if(ReuseTabs){
URLBase := StrReplace(URL,"https://","") URLBase := StrReplace(URL,"https://","")
URLBase := StrSplit(URLBase, "/") URLBase := StrSplit(URLBase, "/")
URLBase := URLBase[1] URLBase := URLBase[1]
URLBase := StrReplace(URLBase, "www.","") URLBase := StrReplace(URLBase, "www.","")
} }
; if base url is not in tab array, create new tab and push url to array if(!HasSubstringVal(DriverURLArray, URLBase)) ; returns position of value in array
if(!HasSubstringVal(DriverURLArray, URLBase))
{ {
try CurrentTabTitle := driver.window.title
; if currently in new tab navigate to the site in the current tab
if(CurrentTabTitle = "New Tab"){
try driver.Get(URL) ;Open selected URL
try driver.executeScript("return document.readyState").equals("complete") ; wait until page loads completely before proceeding
catch e {
; msgbox, error caught. trying something
try driver.switchToalert().accept()
try driver.Get(URL) ;Open selected URL
catch e {
Message = Failed to Navigate to %URL%: Please Check for Any Open Dialogue Boxes
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging")
Return "Failed"
}
}
return
}
else, {
try, run "%ChromeFilepath%" "%URL%" try, run "%ChromeFilepath%" "%URL%"
DriverURLArray.Push(URL) ; Append an item to the array DriverURLArray.Push(URL) ; Append an item to the array
NewTabCreated := 1 NewTabCreated := 1
; sleep, 2000 sleep, 1000
}
} }
; msgbox,
Message = Finding Tab Message = Finding Tab
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile")
@ -1022,8 +977,8 @@ if(TotalTabsFound = 1){
NumberOfTabLoops := DriverURLArray.Length() NumberOfTabLoops := DriverURLArray.Length()
; loop through tabs to find matching tab ; NumberOfTabLoops := Driver.Windows.Count + 2
loop % NumberOfTabLoops { loop % NumberOfTabLoops { ; loop through tabs to find matching tab
try driver.SwitchToNextWindow() try driver.SwitchToNextWindow()
; sleep, 1000 ; sleep, 1000
@ -1031,45 +986,15 @@ if(TotalTabsFound = 1){
try CurrentTabTitle := driver.window.title try CurrentTabTitle := driver.window.title
try CurrentTabURL := driver.Url try CurrentTabURL := driver.Url
; DevModeMsgBox(CurrentTabURL) if(CurrentTabTitle = PageTitle OR InStr(CurrentTabURL, URLBase)){
; DevModeMsgBox(CurrentTabTitle)
; caused by tab being manually closed. Not sure if this is the only cause though.
if(CurrentTabTitle = "") {
Message = CurrentTabTitle: %CurrentTabTitle%
; DevModeMsgBox(Message)
Message = CurrenttabURL: %CurrentTabURL%
; DevModeMsgBox(Message)
; try driver.SwitchToNextWindow
Continue
}
if(InStr(CurrentTabURL, URLBase)){
Message = CurrentTabURL is %CurrentTabURL% and it contains %URLBase%
SaveOrPostProgress(Message:=Message,PostType:="ErrorLoggingTextFile")
; msgbox, found it.`n%CurrentTabTitle% = %PageTitle%`n%CurrentTabURL% = %URLBase% ; msgbox, found it.`n%CurrentTabTitle% = %PageTitle%`n%CurrentTabURL% = %URLBase%
TabFoundSuccessfully := 1 TabFoundSuccessfully := 1
; message = %CurrentTabTitle%: %PageTitle% ; msgbox %CurrentTabTitle% = %PageTitle%
; DevModeMsgBox(message)
; msgbox %CurrentTabURL% = %URL% ; msgbox %CurrentTabURL% = %URL%
Break Break
} }
} }
; if failed to switch to tab and a new tab was not created, then chrome failed to switch to the tab
; this happens sometimes. most likely to a chromedriver bug or maybe tab being offloaded?
if(!TabFoundSuccessfully AND !NewTabCreated){
; @todo : not sure how to best solve this problem currently. It doesn't happen very often.
; last time it happened was when there were only 2 chrome tabs open, gab + subscribestar. chrome was stuck on subscribestar page and wouldn't nextwindow() to gab
}
; Message = TabFoundSuccessfully: %TabFoundSuccessfully%
; DevModeMsgBox(Message)
if(!NewTabCreated){ ; if re-using a tab then we want to re-navigate to URL because it might be the wrong page if(!NewTabCreated){ ; if re-using a tab then we want to re-navigate to URL because it might be the wrong page
try driver.Get(URL) ;Open selected URL try driver.Get(URL) ;Open selected URL
try driver.executeScript("return document.readyState").equals("complete") ; wait until page loads completely before proceeding try driver.executeScript("return document.readyState").equals("complete") ; wait until page loads completely before proceeding
@ -1089,17 +1014,17 @@ if(TotalTabsFound = 1){
Return Return
} }
; End of Function ; End of Function
; -------------------------------/NavigateFromBaseURL------------------------------- ; -------------------------------/NavigateFromBaseURL-------------------------------
SaveDriverURL(){ ; save the url of the result page. That way if a tab is not found for a site, we can open up a tab from this tab instead of middle of nowhere. That way we can keep the tabs together SaveDriverURL(){ ; save the url of the result page. That way if a tab is not found for a site, we can open up a tab from this tab instead of middle of nowhere. That way we can keep the tabs together
try LastWebsitePostURL := driver.URL try LastWebsitePostURL := driver.URL
} }
; -------------------------------SChrome_Get------------------------------- ; -------------------------------SChrome_Get-------------------------------
SChrome_Get(URL := "", Profile := "Profile 1", IP_Port := "127.0.0.1:9222"){ SChrome_Get(URL := "", Profile := "Profile 1", IP_Port := "127.0.0.1:9222"){
IP_Port_Nr := RegExReplace(IP_Port, ".*:(\d*)", "$1") IP_Port_Nr := RegExReplace(IP_Port, ".*:(\d*)", "$1")
if WinExist("ahk_exe Chrome.exe"){ if WinExist("ahk_exe Chrome.exe"){
WinGet, pid, PID, ahk_exe chrome.exe WinGet, pid, PID, ahk_exe chrome.exe
@ -1129,6 +1054,9 @@ SChrome_Get(URL := "", Profile := "Profile 1", IP_Port := "127.0.0.1:9222"){
} }
} }
; ; yuriy's settings
; IniRead, ChromeFilepath, C:\Users\%A_username%\Documents\Autohotkey\Lib\ScriptSettings.ini, Selenium, %A_Computername%, %A_Space%
; ; Establish Variable with Filepath to be used throughout the script ; ; Establish Variable with Filepath to be used throughout the script
; if(ChromeFilepath = ""){ ; if(ChromeFilepath = ""){
if(FileExist("C:\Program Files\Google\Chrome\Application\chrome.exe")){ if(FileExist("C:\Program Files\Google\Chrome\Application\chrome.exe")){
@ -1147,26 +1075,19 @@ SChrome_Get(URL := "", Profile := "Profile 1", IP_Port := "127.0.0.1:9222"){
} }
if(!winExist("ahk_exe chrome.exe")){ if(!winExist("ahk_exe chrome.exe")){
message = %ChromeFilepath% --remote-debugging-port=%IP_Port_Nr% %URL%
; Clipboard := Message
; DevModeMsgBox(message)
run, %ChromeFilepath% --remote-debugging-port=%IP_Port_Nr% %URL% run, %ChromeFilepath% --remote-debugging-port=%IP_Port_Nr% %URL%
} }
; Driver.Timeout := 1000
Driver := ComObjCreate("Selenium.ChromeDriver") Driver := ComObjCreate("Selenium.ChromeDriver")
Driver.SetCapability("debuggerAddress", IP_Port) Driver.SetCapability("debuggerAddress", IP_Port)
SaveOrPostProgress(Message:="Trying to connect to Chrome.`nIf stuck here check for dialog popups in one of your tabs `nOR your ChromeDriver version`nClose chrome to break out of program being stuck.",PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar")
; set selenium timeout to 1 second, instead of default 5 seconds
try Driver.Start() try Driver.Start()
catch e { catch e {
ShowSeleniumErrorMsgbox() ShowSeleniumErrorMsgbox()
}
} ; end of catch
; Save current chrome version to ini file
return Driver return Driver
} }
; -------------------------------/SChrome_Get------------------------------- ; -------------------------------/SChrome_Get-------------------------------
@ -1176,24 +1097,6 @@ SChrome_Get(URL := "", Profile := "Profile 1", IP_Port := "127.0.0.1:9222"){
Chromeversion := RunCMD(GetChromeVersionCommand) Chromeversion := RunCMD(GetChromeVersionCommand)
ChromeVersion := StrReplace(ChromeVersion, "`n", "") ChromeVersion := StrReplace(ChromeVersion, "`n", "")
Message = Failed to connect to Chrome
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging")
/*
; check for alert popup
try alertText := driver.SwitchToAlert().Text
; DevModeMsgBox(alertText)
if(alertText){
Message = Alert Popup Text: %alertText%
SaveOrPostProgress(Message:=Message,PostType:="ErrorLoggingTextFile,ErrorSummaryVar")
SaveOrPostProgress(Message:="Chrome stuck on alert popup",PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging")
DevModeMsgBox("alert popup found")
}
*/
; Msgbox % "alertText: " alertText
; Clipboard := ChromeVersion ; Clipboard := ChromeVersion
; Msgbox % "Chromeversion: " Chromeversion ; Msgbox % "Chromeversion: " Chromeversion
IniRead, PreviousWorkingChromeVersion, Settings.ini, Misc, ChromeVersion, %A_Space% IniRead, PreviousWorkingChromeVersion, Settings.ini, Misc, ChromeVersion, %A_Space%
@ -1203,7 +1106,7 @@ SChrome_Get(URL := "", Profile := "Profile 1", IP_Port := "127.0.0.1:9222"){
; SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") ; SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging")
OnMessage(0x44, "OnMsgBoxChromeDriverFailed") OnMessage(0x44, "OnMsgBoxChromeDriverFailed")
MsgBox 0x40043, Error, Failed to Connect to Chrome. `nMost likely issue is either Chrome has some sort of dialogue box open or ChromeDriver needs to be updated.`n`nClick "Reload" to reload with your Last Post`nClick "ChromeDriver" to open up the ChromeDriver download page. `n`nClick "Instructions" to open up installation instructions in your default browser.`n`n Information:`nCurrent Chrome Version: %Chromeversion%Chrome Version of Last Successfull Upload: %PreviousWorkingChromeVersion% MsgBox 0x40043, Error, Failed to Connect to Chrome. `nMost likely issue is either Chrome has some sort of dialogue box open or ChromeDriver needs to be updated.`n`nClick "Reload" to reload the script to try again`nClick "ChromeDriver" to open up the ChromeDriver download page. `n`nClick "Instructions" to open up .pdf file with instructions for updating chromedriver.exe`n`nPossibly Helpful Info:`nCurrent Chrome Version: %Chromeversion%Chrome Version of Last Successfull Upload: %PreviousWorkingChromeVersion%
OnMessage(0x44, "") OnMessage(0x44, "")
IfMsgBox Yes, { IfMsgBox Yes, {
@ -1211,13 +1114,18 @@ SChrome_Get(URL := "", Profile := "Profile 1", IP_Port := "127.0.0.1:9222"){
Reload Reload
} Else IfMsgBox No, { } Else IfMsgBox No, {
run, https://chromedriver.chromium.org/downloads run, https://chromedriver.chromium.org/downloads
run, "%A_ScriptFullPath%" "LastPost"
ExitApp ExitApp
; open chromedriver site ; open chromedriver site
} Else IfMsgBox Cancel, { } Else IfMsgBox Cancel, {
run, "https://git.zinchuk.xyz/yuriy/Freedomain-Social-Media-Poster#installation" URL = https://freedomainplaylists.com/wp-content/FreedomainScripts/Update`%20Selenium`%20ChromeDriver.pdf
run, "%A_ScriptFullPath%" "LastPost" Filepath = %A_ScriptDir%\Lib\Update Selenium ChromeDriver.pdf
if(!FileExist(Filepath)){
UrlDownloadToFile, %URL%, %Filepath%
run, %Filepath%
}
ExitApp ExitApp
} }
} }
@ -1494,22 +1402,13 @@ SaveDriverURLOFErrorPage(){ ; save the url of the result page. That way if a tab
FindAndActivateTab(TabURL){ FindAndActivateTab(TabURL){
; DevModeMsgBox(TabURL)
Loop, { Loop, {
if(A_index = 30) if(A_index = 30)
break break
try CurrentTabTitle := driver.window.title try CurrentTabTitle := driver.window.title
if(CurrentTabTitle = "") ; caused by tab being manually closed. Not sure if this is the only cause though.
{
; DevModeMsgBox("currenttabtutle is blank")
try driver.SwitchToNextWindow
Continue
}
; DevModeMsgBox(CurrentTabTitle)
try CurrentTabURL := driver.Url try CurrentTabURL := driver.Url
; DevModeMsgBox(CurrentTabURL)
if(CurrentTabURL = TabURL) if(CurrentTabURL = TabURL)
Break Break

Loading…
Cancel
Save