Compare commits
1 Commits
5671242faf
...
b8ffb10db1
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b8ffb10db1 |
@@ -21,6 +21,9 @@ global InstalledChromeVersion
|
|||||||
; Chrome Related Functions
|
; Chrome Related Functions
|
||||||
;------------------------------------------------
|
;------------------------------------------------
|
||||||
DownloadLatestChromium(){
|
DownloadLatestChromium(){
|
||||||
|
Message = Checking Variables for Downloading Newest Chrome
|
||||||
|
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
|
||||||
|
|
||||||
if(ChromeFilepath = "")
|
if(ChromeFilepath = "")
|
||||||
ChromeFilepath := GetInstalledChromeFilepath()
|
ChromeFilepath := GetInstalledChromeFilepath()
|
||||||
|
|
||||||
@@ -90,9 +93,9 @@ DownloadLatestChromium(){
|
|||||||
|
|
||||||
|
|
||||||
; close any open instances of Chromium
|
; close any open instances of Chromium
|
||||||
SetTitleMatchMode, 2 ; substring
|
; SetTitleMatchMode, 2 ; substring
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
if(WinExist(" - Chromium")){
|
if(WinExist(" - Chromium")){
|
||||||
Message = Trying to close any open Chromium Windows
|
Message = Trying to close any open Chromium Windows
|
||||||
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
|
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
|
||||||
@@ -111,292 +114,339 @@ DownloadLatestChromium(){
|
|||||||
MsgBox 0x10,, %Message%
|
MsgBox 0x10,, %Message%
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
; make sure all instances of chrome are closed
|
||||||
|
Loop, {
|
||||||
|
ChromeOpen := WinExist("ahk_exe chrome.exe")
|
||||||
|
if(ChromeOpen) {
|
||||||
|
Message = Chrome is Open. Asking user to close instances before continuing.
|
||||||
|
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
|
||||||
|
|
||||||
; msgbox
|
MsgBox 0x41, Chrome is Open, Please close all instances of Chrome and then click OK to continue with replacing Chrome with the newest version.
|
||||||
|
|
||||||
FileGetTime, ChromeDriverExeOldCreationTime, %ChromeDriverProgramFilesExeFilepath%, C
|
IfMsgBox OK, {
|
||||||
|
|
||||||
|
} Else IfMsgBox Cancel, {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
else,
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Message = Downloading Chromedriver v%ChromeStableLatestVersion% to:`n%ChromeDriverDownloadZipFilepath%
|
; make sure all instances of chromedriver.exe are closed
|
||||||
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
|
Message = Checking and killing any instances of the chromedriver.exe process
|
||||||
UrlDownloadToFile, %chromedriverDLURL64%, %ChromeDriverDownloadZipFilepath%
|
|
||||||
|
|
||||||
Message = Downloading Chromium v%ChromeStableLatestVersion% to:`n%ChromeDownloadZipFilepath%
|
|
||||||
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
|
|
||||||
UrlDownloadToFile, %chromeDLURL64%, %ChromeDownloadZipFilepath%
|
|
||||||
|
|
||||||
|
|
||||||
; delete the pre-existing chrome-win64 directory
|
|
||||||
Message = Deleting Old Chromium Directory
|
|
||||||
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
|
|
||||||
|
|
||||||
FileRemoveDir, %ChromeExtractedDirectory%, 1
|
|
||||||
if(FileExist(ChromeExtractedDirectory)){
|
|
||||||
Message = Failed to delete the old Chromium. `nPlease manually delete the following directory and then run the Chrome Update again.`n`n %ChromeExtractedDirectory%
|
|
||||||
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar")
|
|
||||||
|
|
||||||
MsgBox 0x10,, %Message%
|
|
||||||
|
|
||||||
ToolTip
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
; Double check that .zip files exist
|
|
||||||
ChromeDriverZipExists := FileExist(ChromeDriverDownloadZipFilepath)
|
|
||||||
if(!ChromeDriverZipExists){
|
|
||||||
Message = Download of chromedriver failed for some reason. chromedriver.zip not found.
|
|
||||||
SaveOrPostProgress(Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging")
|
|
||||||
MsgBox 0x10,, %Message%
|
|
||||||
Return
|
|
||||||
}
|
|
||||||
|
|
||||||
ChromeZipExists := FileExist(ChromeDownloadZipFilepath)
|
|
||||||
if(!ChromeZipExists){
|
|
||||||
Message = Download of chrome failed for some reason. chrome.zip not found.
|
|
||||||
SaveOrPostProgress(Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging")
|
|
||||||
MsgBox 0x10,, %Message%
|
|
||||||
Return
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Message = Extracting Chromedriver v%ChromeStableLatestVersion% Zip file
|
|
||||||
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
|
|
||||||
Unzip(ChromeDriverDownloadZipFilepath, ChromeDriverDownloadFilepath)
|
|
||||||
|
|
||||||
Message = Extracting Chromium v%ChromeStableLatestVersion% Zip file
|
|
||||||
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
|
|
||||||
Unzip(ChromeDownloadZipFilepath, ChromeExtractedDirectory)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
; Check if the Copy-ChromeDriver-To-Program-Files.exe file exists
|
|
||||||
|
|
||||||
; @todo, remove later. this is temporary to fix chromedriver-mover being broken and needing to be replaced
|
|
||||||
FileDelete, %ChromeDriverMoverEXEFilepath%
|
|
||||||
|
|
||||||
Message = Checking Chromedriver-Mover.exe exists
|
|
||||||
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
|
|
||||||
|
|
||||||
if(!FileExist(ChromeDriverMoverEXEFilepath)){
|
|
||||||
Message = Chromedriver-Mover not found. Downloading from Gitea
|
|
||||||
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
|
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
|
||||||
|
|
||||||
UrlDownloadToFile, %ChromeDriverMoverURL%, %ChromeDriverMoverEXEFilepath%
|
Loop, 5 {
|
||||||
if(ErrorLevel){
|
|
||||||
Message = Failed to download the Copy-ChromeDriver-To-Program-Files.exe executable. `n`n%ManualMoveChromedriverMessage%
|
Process, Exist, chromedriver.exe
|
||||||
|
ChromedriverExists := ErrorLevel
|
||||||
|
|
||||||
|
if(ChromedriverExists){
|
||||||
|
Message = Chromedriver Exists on check number %A_Index%
|
||||||
|
SaveOrPostProgress(Message:=Message,PostType:="ErrorLoggingTextFile,DiscordErrorLogging")
|
||||||
|
|
||||||
|
Process, Close, chromedriver.exe
|
||||||
|
sleep, 5000 ; wait 5 seconds before checking again
|
||||||
|
}
|
||||||
|
else,
|
||||||
|
break
|
||||||
|
|
||||||
|
Message = Chrome Update Failed. Unable to kill background chromedriver.exe process
|
||||||
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging")
|
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging")
|
||||||
|
return
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
FileGetTime, ChromeDriverExeOldCreationTime, %ChromeDriverProgramFilesExeFilepath%, C
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Message = Downloading Chromedriver v%ChromeStableLatestVersion% `nFrom: %chromedriverDLURL64%`nTo: %ChromeDriverDownloadZipFilepath%
|
||||||
|
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
|
||||||
|
UrlDownloadToFile, %chromedriverDLURL64%, %ChromeDriverDownloadZipFilepath%
|
||||||
|
|
||||||
|
Message = Downloading Chromium v%ChromeStableLatestVersion% `nfrom: %chromeDLURL64% to:`n%ChromeDownloadZipFilepath%`n(This might take 1-2 minutes)
|
||||||
|
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
|
||||||
|
UrlDownloadToFile, %chromeDLURL64%, %ChromeDownloadZipFilepath%
|
||||||
|
|
||||||
|
|
||||||
|
; delete the pre-existing chrome-win64 directory
|
||||||
|
Message = Deleting Old Chromium Directory
|
||||||
|
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
FileRemoveDir, %ChromeExtractedDirectory%, 1
|
||||||
|
if(FileExist(ChromeExtractedDirectory)){
|
||||||
|
Message = Failed to delete the old Chromium. `nPlease manually delete the following directory and then run the Chrome Update again.`n`n %ChromeExtractedDirectory%
|
||||||
|
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar")
|
||||||
|
|
||||||
|
MsgBox 0x10,, %Message%
|
||||||
|
|
||||||
ToolTip
|
ToolTip
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
; Double check that .zip files exist
|
||||||
|
ChromeDriverZipExists := FileExist(ChromeDriverDownloadZipFilepath)
|
||||||
|
if(!ChromeDriverZipExists){
|
||||||
|
Message = Download of chromedriver failed for some reason. chromedriver.zip not found.
|
||||||
|
SaveOrPostProgress(Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging")
|
||||||
|
MsgBox 0x10,, %Message%
|
||||||
|
Return
|
||||||
|
}
|
||||||
|
|
||||||
|
ChromeZipExists := FileExist(ChromeDownloadZipFilepath)
|
||||||
|
if(!ChromeZipExists){
|
||||||
|
Message = Download of chrome failed for some reason. chrome.zip not found.
|
||||||
|
SaveOrPostProgress(Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging")
|
||||||
|
MsgBox 0x10,, %Message%
|
||||||
Return
|
Return
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if(!FileExist(ChromeDriverMoverEXEFilepath)){
|
|
||||||
Message = ChromeDriver-Mover not found after downloading. `nPossibly triggered and deleted by Antivirus?`n`n%ManualMoveChromedriverMessage%
|
|
||||||
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging,msgbox")
|
|
||||||
|
|
||||||
ToolTip
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
Message = Starting up Chromedriver-Mover
|
|
||||||
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
|
|
||||||
|
|
||||||
|
|
||||||
; Msgbox % "ChromeDriverMoverEXEFilepath: " ChromeDriverMoverEXEFilepath
|
Message = Extracting Chromedriver v%ChromeStableLatestVersion% Zip file
|
||||||
; Msgbox % "ChromeDriverDownloadFilepath: " ChromeDriverDownloadFilepath
|
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
|
||||||
|
Unzip(ChromeDriverDownloadZipFilepath, ChromeDriverDownloadFilepath)
|
||||||
|
|
||||||
try, Run "%ChromeDriverMoverEXEFilepath%" "%ChromeDriverDownloadFilepath%"
|
Message = Extracting Chromium v%ChromeStableLatestVersion% Zip file
|
||||||
if(ErrorLevel = "ERROR"){
|
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
|
||||||
Message = Failed to run Chromedriver-Mover.exe program to automatically copy the chromedriver to Program Files.`n%ManualMoveChromedriverMessage%
|
Unzip(ChromeDownloadZipFilepath, ChromeExtractedDirectory)
|
||||||
MsgBox 0x40,, %Message%
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
Message = Waiting 30 seconds for new Chromedriver to get moved to C:\Program Files\SeleniumBasic\
|
|
||||||
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
|
|
||||||
|
|
||||||
Loop, 30 {
|
|
||||||
sleep, 1000
|
|
||||||
|
|
||||||
FileGetTime, ChromeDriverExeCurrentCreationTime, %ChromeDriverProgramFilesExeFilepath%, C
|
; Check if the Copy-ChromeDriver-To-Program-Files.exe file exists
|
||||||
|
|
||||||
; Msgbox % "ChromeDriverExeOldCreationTime: " ChromeDriverExeOldCreationTime
|
; @todo, remove later. this is temporary to fix chromedriver-mover being broken and needing to be replaced
|
||||||
; Msgbox % "ChromeDriverExeCurrentCreationTime: " ChromeDriverExeCurrentCreationTime
|
FileDelete, %ChromeDriverMoverEXEFilepath%
|
||||||
|
|
||||||
if(ErrorLevel){
|
Message = Checking Chromedriver-Mover.exe exists
|
||||||
|
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
|
||||||
|
|
||||||
Message = chromedriver.exe not found in %ChromeDriverProgramFilesExeFilepath%. `nWaiting for new version to get copied over.
|
if(!FileExist(ChromeDriverMoverEXEFilepath)){
|
||||||
|
Message = Chromedriver-Mover not found. Downloading from Gitea
|
||||||
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
|
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
|
||||||
|
|
||||||
|
UrlDownloadToFile, %ChromeDriverMoverURL%, %ChromeDriverMoverEXEFilepath%
|
||||||
|
if(ErrorLevel){
|
||||||
|
Message = Failed to download the Copy-ChromeDriver-To-Program-Files.exe executable. `n`n%ManualMoveChromedriverMessage%
|
||||||
|
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging")
|
||||||
|
|
||||||
|
ToolTip
|
||||||
|
Return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if(!FileExist(ChromeDriverMoverEXEFilepath)){
|
||||||
|
Message = ChromeDriver-Mover not found after downloading. `nPossibly triggered and deleted by Antivirus?`n`n%ManualMoveChromedriverMessage%
|
||||||
|
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging,msgbox")
|
||||||
|
|
||||||
|
ToolTip
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
Message = Starting up Chromedriver-Mover
|
||||||
|
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
|
||||||
|
|
||||||
|
|
||||||
|
; Msgbox % "ChromeDriverMoverEXEFilepath: " ChromeDriverMoverEXEFilepath
|
||||||
|
; Msgbox % "ChromeDriverDownloadFilepath: " ChromeDriverDownloadFilepath
|
||||||
|
|
||||||
|
try, Run "%ChromeDriverMoverEXEFilepath%" "%ChromeDriverDownloadFilepath%"
|
||||||
|
if(ErrorLevel = "ERROR"){
|
||||||
|
Message = Failed to run Chromedriver-Mover.exe program to automatically copy the chromedriver to Program Files.`n%ManualMoveChromedriverMessage%
|
||||||
|
MsgBox 0x40,, %Message%
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Message = Waiting 30 seconds for new Chromedriver to get moved to C:\Program Files\SeleniumBasic\
|
||||||
|
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
|
||||||
|
|
||||||
|
Loop, 30 {
|
||||||
|
sleep, 1000
|
||||||
|
|
||||||
|
FileGetTime, ChromeDriverExeCurrentCreationTime, %ChromeDriverProgramFilesExeFilepath%, C
|
||||||
|
|
||||||
|
; Msgbox % "ChromeDriverExeOldCreationTime: " ChromeDriverExeOldCreationTime
|
||||||
|
; Msgbox % "ChromeDriverExeCurrentCreationTime: " ChromeDriverExeCurrentCreationTime
|
||||||
|
|
||||||
|
if(ErrorLevel){
|
||||||
|
|
||||||
|
Message = chromedriver.exe not found in %ChromeDriverProgramFilesExeFilepath%. `nWaiting for new version to get copied over.
|
||||||
|
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
|
||||||
|
; sleep, 1000
|
||||||
|
Continue
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if(ChromeDriverExeCurrentCreationTime != ChromeDriverExeOldCreationTime and ChromeDriverExeCurrentCreationTime != ""){
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
; sleep, 1000
|
; sleep, 1000
|
||||||
Continue
|
Continue
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(ChromeDriverExeCurrentCreationTime != ChromeDriverExeOldCreationTime and ChromeDriverExeCurrentCreationTime != ""){
|
if(!FileExist(ChromeDriverProgramFilesExeFilepath)){
|
||||||
break
|
Message = Failed to Automatically move chromedriver.exe`n%ManualMoveChromedriverMessage%
|
||||||
|
MsgBox 0x40,, %Message%
|
||||||
|
ToolTip
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
; sleep, 1000
|
Message = Chromium and Chromedriver.exe were updated successfully.
|
||||||
Continue
|
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
|
||||||
}
|
|
||||||
|
|
||||||
if(!FileExist(ChromeDriverProgramFilesExeFilepath)){
|
|
||||||
Message = Failed to Automatically move chromedriver.exe`n%ManualMoveChromedriverMessage%
|
|
||||||
MsgBox 0x40,, %Message%
|
MsgBox 0x40,, %Message%
|
||||||
|
|
||||||
ToolTip
|
ToolTip
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
Message = Chromium and Chromedriver.exe were updated successfully.
|
|
||||||
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
|
|
||||||
MsgBox 0x40,, %Message%
|
|
||||||
|
|
||||||
ToolTip
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
CheckForChromeUpdates(ChromeFilepath := ""){
|
||||||
|
if(ChromeFilepath = "")
|
||||||
|
ChromeFilepath := GetInstalledChromeFilepath()
|
||||||
|
|
||||||
CheckForChromeUpdates(ChromeFilepath := ""){
|
CurrentInstalledChromeVersion := GetInstalledChromeVersion()
|
||||||
if(ChromeFilepath = "")
|
CurrentChromeStableVersion := GetLatestChromeStableVersion()
|
||||||
ChromeFilepath := GetInstalledChromeFilepath()
|
|
||||||
|
|
||||||
CurrentInstalledChromeVersion := GetInstalledChromeVersion()
|
if(CurrentInstalledChromeVersion < CurrentChromeStableVersion){
|
||||||
CurrentChromeStableVersion := GetLatestChromeStableVersion()
|
ChromeUpdateAvailable := 1
|
||||||
|
return ChromeUpdateAvailable
|
||||||
if(CurrentInstalledChromeVersion < CurrentChromeStableVersion){
|
|
||||||
ChromeUpdateAvailable := 1
|
|
||||||
return ChromeUpdateAvailable
|
|
||||||
}
|
|
||||||
else, Return 0
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
GetInstalledChromeFilepath(){
|
|
||||||
; ChromeFilepath is global variable
|
|
||||||
|
|
||||||
if(ChromeFilepath = ""){
|
|
||||||
|
|
||||||
ChromePortableFilepath = %A_ScriptDir%\Lib\chrome-win64\chrome.exe
|
|
||||||
ChromePortableFilepath2 = %A_ScriptDir%\Lib\chrome-win64\chrome-win64\chrome.exe ; filepath of chrome.exe that was downloaded automatically using this uploader
|
|
||||||
|
|
||||||
if(FileExist(ChromePortableFilepath) or FileExist(ChromePortableFilepath2)){
|
|
||||||
if(FileExist(ChromePortableFilepath2))
|
|
||||||
ChromeFilepath := ChromePortableFilepath2
|
|
||||||
|
|
||||||
if(FileExist(ChromePortableFilepath))
|
|
||||||
ChromeFilepath := ChromePortableFilepath
|
|
||||||
|
|
||||||
Message = Using Chromium Portable for Upload
|
|
||||||
SaveOrPostProgress(Message:=Message,PostType:="ErrorLoggingTextFile,DiscordErrorLogging")
|
|
||||||
}
|
}
|
||||||
else {
|
else, Return 0
|
||||||
MsgBox 0x10, Chromium Portable not Found, Chromium Portable not found. `nPlease make sure it's located at one of the following paths and then try again.`n`n%ChromePortableFilepath% `nOR`n%ChromePortableFilepath2%
|
|
||||||
|
|
||||||
|
|
||||||
; Leave this in for now, but i don't think we will be going to using the system Chrome in the future.
|
}
|
||||||
; if(FileExist("C:\Program Files (x86)\Google\Chrome\Application\chrome.exe"))
|
|
||||||
; ChromeFilepath = C:\Program Files (x86)\Google\Chrome\Application\chrome.exe
|
|
||||||
|
|
||||||
; if(FileExist("C:\Program Files\Google\Chrome\Application\chrome.exe"))
|
|
||||||
; ChromeFilepath = C:\Program Files\Google\Chrome\Application\chrome.exe
|
GetInstalledChromeFilepath(){
|
||||||
|
; ChromeFilepath is global variable
|
||||||
|
|
||||||
|
if(ChromeFilepath = ""){
|
||||||
|
|
||||||
|
ChromePortableFilepath = %A_ScriptDir%\Lib\chrome-win64\chrome.exe
|
||||||
|
ChromePortableFilepath2 = %A_ScriptDir%\Lib\chrome-win64\chrome-win64\chrome.exe ; filepath of chrome.exe that was downloaded automatically using this uploader
|
||||||
|
|
||||||
|
if(FileExist(ChromePortableFilepath) or FileExist(ChromePortableFilepath2)){
|
||||||
|
if(FileExist(ChromePortableFilepath2))
|
||||||
|
ChromeFilepath := ChromePortableFilepath2
|
||||||
|
|
||||||
|
if(FileExist(ChromePortableFilepath))
|
||||||
|
ChromeFilepath := ChromePortableFilepath
|
||||||
|
|
||||||
|
Message = Using Chromium Portable for Upload
|
||||||
|
SaveOrPostProgress(Message:=Message,PostType:="ErrorLoggingTextFile,DiscordErrorLogging")
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
MsgBox 0x10, Chromium Portable not Found, Chromium Portable not found. `nPlease make sure it's located at one of the following paths and then try again.`n`n%ChromePortableFilepath% `nOR`n%ChromePortableFilepath2%
|
||||||
|
|
||||||
|
|
||||||
|
; Leave this in for now, but i don't think we will be going to using the system Chrome in the future.
|
||||||
|
; if(FileExist("C:\Program Files (x86)\Google\Chrome\Application\chrome.exe"))
|
||||||
|
; ChromeFilepath = C:\Program Files (x86)\Google\Chrome\Application\chrome.exe
|
||||||
|
|
||||||
|
; if(FileExist("C:\Program Files\Google\Chrome\Application\chrome.exe"))
|
||||||
|
; ChromeFilepath = C:\Program Files\Google\Chrome\Application\chrome.exe
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
ToolTip
|
||||||
ToolTip
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
GetInstalledChromeVersion(){
|
|
||||||
|
|
||||||
if(ChromeFilepath = ""){
|
|
||||||
GetInstalledChromeFilepath()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
GetInstalledChromeVersionCommand = powershell (Get-Item '%ChromeFilepath%').VersionInfo.ProductVersion
|
GetInstalledChromeVersion(){
|
||||||
InstalledChromeVersion := RunCMD(GetInstalledChromeVersionCommand)
|
|
||||||
|
|
||||||
if(InStr(InstalledChromeVersion, "`r"))
|
if(ChromeFilepath = ""){
|
||||||
InstalledChromeVersion := StrReplace(InstalledChromeVersion, "`r") ; replace any newline characters that powershell returns
|
GetInstalledChromeFilepath()
|
||||||
|
|
||||||
return InstalledChromeVersion
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
GetLatestChromeStableVersion(){
|
|
||||||
|
|
||||||
; https://github.com/GoogleChromeLabs/chrome-for-testing#json-api-endpoints
|
|
||||||
json_str := urldownloadtovar("https://googlechromelabs.github.io/chrome-for-testing/last-known-good-versions.json")
|
|
||||||
|
|
||||||
|
|
||||||
; converts json data variable into object
|
|
||||||
parsed := JSON.Load(json_str)
|
|
||||||
|
|
||||||
|
|
||||||
try ChromeStableLatestVersion := parsed.channels.stable.version
|
|
||||||
|
|
||||||
if(ChromeStableLatestVersion = ""){
|
|
||||||
return "Failed to parse json. "
|
|
||||||
}
|
|
||||||
|
|
||||||
return ChromeStableLatestVersion
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
GetDownloadURLOfChromeAndDriver(InstalledChromeVersion){
|
|
||||||
; Will return the download URL of Chrome for Testing and Chrome Driver, seperated by a ||
|
|
||||||
|
|
||||||
; https://github.com/GoogleChromeLabs/chrome-for-testing#json-api-endpoints
|
|
||||||
json_str := urldownloadtovar("https://googlechromelabs.github.io/chrome-for-testing/known-good-versions-with-downloads.json")
|
|
||||||
|
|
||||||
; requires #include of json.ahk in parent script
|
|
||||||
parsed := JSON.Load(json_str)
|
|
||||||
|
|
||||||
ChromelabsJsonEntriesCount := parsed.versions.count()
|
|
||||||
|
|
||||||
if(ChromelabsJsonEntriesCount = ""){
|
|
||||||
return "Failed to parse chromedriver json. "
|
|
||||||
}
|
|
||||||
|
|
||||||
loop % ChromelabsJsonEntriesCount {
|
|
||||||
|
|
||||||
if(A_index = ChromelabsJsonEntriesCount){
|
|
||||||
Message = "Failed to find %InstalledChromeVersion% in the ChromeLabs Json"
|
|
||||||
return Message
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(InstalledChromeVersion = parsed.versions[A_Index].version){
|
GetInstalledChromeVersionCommand = powershell (Get-Item '%ChromeFilepath%').VersionInfo.ProductVersion
|
||||||
|
InstalledChromeVersion := RunCMD(GetInstalledChromeVersionCommand)
|
||||||
|
|
||||||
VersionIndex := A_Index
|
if(InStr(InstalledChromeVersion, "`r"))
|
||||||
|
InstalledChromeVersion := StrReplace(InstalledChromeVersion, "`r") ; replace any newline characters that powershell returns
|
||||||
|
|
||||||
; loop through the platforms to get download URL for Chrome
|
return InstalledChromeVersion
|
||||||
loop % parsed.versions[VersionIndex].downloads.chrome.count() {
|
}
|
||||||
|
|
||||||
if(parsed.versions[VersionIndex].downloads.chrome[A_Index].platform = "win64")
|
|
||||||
chromeDLURL64 := parsed.versions[VersionIndex].downloads.chrome[A_Index].url
|
GetLatestChromeStableVersion(){
|
||||||
|
|
||||||
|
; https://github.com/GoogleChromeLabs/chrome-for-testing#json-api-endpoints
|
||||||
|
json_str := urldownloadtovar("https://googlechromelabs.github.io/chrome-for-testing/last-known-good-versions.json")
|
||||||
|
|
||||||
|
|
||||||
|
; converts json data variable into object
|
||||||
|
parsed := JSON.Load(json_str)
|
||||||
|
|
||||||
|
|
||||||
|
try ChromeStableLatestVersion := parsed.channels.stable.version
|
||||||
|
|
||||||
|
if(ChromeStableLatestVersion = ""){
|
||||||
|
return "Failed to parse json. "
|
||||||
|
}
|
||||||
|
|
||||||
|
return ChromeStableLatestVersion
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
GetDownloadURLOfChromeAndDriver(InstalledChromeVersion){
|
||||||
|
; Will return the download URL of Chrome for Testing and Chrome Driver, seperated by a ||
|
||||||
|
|
||||||
|
; https://github.com/GoogleChromeLabs/chrome-for-testing#json-api-endpoints
|
||||||
|
json_str := urldownloadtovar("https://googlechromelabs.github.io/chrome-for-testing/known-good-versions-with-downloads.json")
|
||||||
|
|
||||||
|
; requires #include of json.ahk in parent script
|
||||||
|
parsed := JSON.Load(json_str)
|
||||||
|
|
||||||
|
ChromelabsJsonEntriesCount := parsed.versions.count()
|
||||||
|
|
||||||
|
if(ChromelabsJsonEntriesCount = ""){
|
||||||
|
return "Failed to parse chromedriver json. "
|
||||||
|
}
|
||||||
|
|
||||||
|
loop % ChromelabsJsonEntriesCount {
|
||||||
|
|
||||||
|
if(A_index = ChromelabsJsonEntriesCount){
|
||||||
|
Message = "Failed to find %InstalledChromeVersion% in the ChromeLabs Json"
|
||||||
|
return Message
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(InstalledChromeVersion = parsed.versions[A_Index].version){
|
||||||
|
|
||||||
; loop through the platforms to get download URL for Chromedriver
|
VersionIndex := A_Index
|
||||||
loop % parsed.versions[VersionIndex].downloads.chromedriver.count() {
|
|
||||||
|
; loop through the platforms to get download URL for Chrome
|
||||||
if(parsed.versions[VersionIndex].downloads.chromedriver[A_Index].platform = "win64")
|
loop % parsed.versions[VersionIndex].downloads.chrome.count() {
|
||||||
chromedriverDLURL64 := parsed.versions[VersionIndex].downloads.chromedriver[A_Index].url
|
|
||||||
|
if(parsed.versions[VersionIndex].downloads.chrome[A_Index].platform = "win64")
|
||||||
|
chromeDLURL64 := parsed.versions[VersionIndex].downloads.chrome[A_Index].url
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
; loop through the platforms to get download URL for Chromedriver
|
||||||
|
loop % parsed.versions[VersionIndex].downloads.chromedriver.count() {
|
||||||
|
|
||||||
|
if(parsed.versions[VersionIndex].downloads.chromedriver[A_Index].platform = "win64")
|
||||||
|
chromedriverDLURL64 := parsed.versions[VersionIndex].downloads.chromedriver[A_Index].url
|
||||||
|
}
|
||||||
|
|
||||||
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
break
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
URLS = %chromeDLURL64%||%chromedriverDLURL64%
|
URLS = %chromeDLURL64%||%chromedriverDLURL64%
|
||||||
return URLS
|
return URLS
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user