@ -15,6 +15,7 @@ global CurrentTabURL
; #Include %A_ScriptDir%\RunCMD.ahk
; #Include %A_ScriptDir%\RunCMD.ahk
; @todo: add error checks for all winhttp requests.
DevModeMsgBox(Message){
DevModeMsgBox(Message){
@ -26,7 +27,7 @@ DevModeMsgBox(Message){
}
}
CheckForUpdates(){
CheckForUpdates(GitReleasesAPIURL ){
; msgbox, checking for updates
; msgbox, checking for updates
Message = Checking For Updates
Message = Checking For Updates
SaveOrPostProgress(Message,PostType:="ErrorLoggingTextFile")
SaveOrPostProgress(Message,PostType:="ErrorLoggingTextFile")
@ -174,6 +175,7 @@ TakeScreenshotOfPage(SaveFilepath := ""){
; -------------------------------TooltipThis-------------------------------
; -------------------------------TooltipThis-------------------------------
TooltipThis(String){
TooltipThis(String){
; msgbox
; Xposition := StrLen(String)
; Xposition := StrLen(String)
StringFirstLine := StrSplit(String, "`n")
StringFirstLine := StrSplit(String, "`n")
StringFirstLine := StringFirstLine[1]
StringFirstLine := StringFirstLine[1]
@ -922,7 +924,9 @@ if(TotalTabsFound = 1){
; / END OF FUNC
; / END OF FUNC
}
}
InputFilePathIntoOpenWindow(Filepath){
/*
*/
InputFilePathIntoOpenWindow(Filepath){
; Msgbox % "Filepath: " Filepath
; Msgbox % "Filepath: " Filepath
Message = Waiting for "Open" window to appear to input filepath into
Message = Waiting for "Open" window to appear to input filepath into
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile")
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile")
@ -946,9 +950,9 @@ if(TotalTabsFound = 1){
if(OpenWindowExist)
if(OpenWindowExist)
ControlSend, Edit1, {Enter}, Open
ControlSend, Edit1, {Enter}, Open
ToolTip,
ToolTip,
}
}
CheckCurrentTabForCurrentSite(){
CheckCurrentTabForCurrentSite(){
try CurrentTabURL := driver.url
try CurrentTabURL := driver.url
if(!InStr(CurrentTabURL, CurrentSite)){
if(!InStr(CurrentTabURL, CurrentSite)){
@ -962,11 +966,11 @@ if(TotalTabsFound = 1){
; msgbox % InStr(CurrentTabURL,CurrentSite)
; msgbox % InStr(CurrentTabURL,CurrentSite)
}
}
; -------------------------------NavigateFromBaseURLTo-------------------------------
; -------------------------------NavigateFromBaseURLTo-------------------------------
NavigateFromBaseURLTo(URL){
NavigateFromBaseURLTo(URL, Title:="REmoveMe" ){
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)
@ -981,11 +985,11 @@ if(TotalTabsFound = 1){
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 base url is not in tab array, create new tab and push url to array
if(!HasSubstringVal(DriverURLArray, URLBase))
if(!HasSubstringVal(DriverURLArray, URLBase))
{
{
try CurrentTabTitle := driver.window.title
try CurrentTabTitle := driver.window.title
; if currently in new tab navigate to the site in the current tab
; if currently in new tab navigate to the site in the current tab
@ -1013,17 +1017,17 @@ if(TotalTabsFound = 1){
}
}
Message = Finding Tab
Message = Finding Tab
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile")
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile")
TabFoundSuccessfully :=
TabFoundSuccessfully :=
NumberOfTabLoops := DriverURLArray.Length()
NumberOfTabLoops := DriverURLArray.Length()
; loop through tabs to find matching tab
; loop through tabs to find matching tab
loop % NumberOfTabLoops {
loop % NumberOfTabLoops {
try driver.SwitchToNextWindow()
try driver.SwitchToNextWindow()
; sleep, 1000
; sleep, 1000
@ -1044,10 +1048,10 @@ if(TotalTabsFound = 1){
; try driver.SwitchToNextWindow
; try driver.SwitchToNextWindow
Continue
Continue
}
}
if(InStr(CurrentTabURL, URLBase)){
if(InStr(CurrentTabURL, URLBase)){
Message = CurrentTabURL is %CurrentTabURL% and it contains %URLBase%
Message = CurrentTabURL is %CurrentTabURL% and it contains %URLBase%
SaveOrPostProgress(Message:=Message,PostType:="ErrorLoggingTextFile")
SaveOrPostProgress(Message:=Message,PostType:="ErrorLoggingTextFile")
@ -1057,20 +1061,20 @@ if(TotalTabsFound = 1){
; DevModeMsgBox(message)
; 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
; 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?
; this happens sometimes. most likely to a chromedriver bug or maybe tab being offloaded?
if(!TabFoundSuccessfully AND !NewTabCreated){
if(!TabFoundSuccessfully AND !NewTabCreated){
; @todo : not sure how to best solve this problem currently. It doesn't happen very often.
; @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
; 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%
; Message = TabFoundSuccessfully: %TabFoundSuccessfully%
; DevModeMsgBox(Message)
; 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
catch e {
catch e {
@ -1083,12 +1087,12 @@ if(TotalTabsFound = 1){
Return "Failed"
Return "Failed"
}
}
}
}
}
}
; msgbox, no error caught
; msgbox, no error caught
; }
; }
Return
Return
}
}
; End of Function
; End of Function
; -------------------------------/NavigateFromBaseURL-------------------------------
; -------------------------------/NavigateFromBaseURL-------------------------------