improved chrome update functionality

main
Yuriy 5 months ago
parent 5671242faf
commit b8ffb10db1

@ -21,6 +21,9 @@ global InstalledChromeVersion
; Chrome Related Functions
;------------------------------------------------
DownloadLatestChromium(){
Message = Checking Variables for Downloading Newest Chrome
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
if(ChromeFilepath = "")
ChromeFilepath := GetInstalledChromeFilepath()
@ -90,9 +93,9 @@ DownloadLatestChromium(){
; close any open instances of Chromium
SetTitleMatchMode, 2 ; substring
; SetTitleMatchMode, 2 ; substring
/*
if(WinExist(" - Chromium")){
Message = Trying to close any open Chromium Windows
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
@ -111,19 +114,64 @@ DownloadLatestChromium(){
MsgBox 0x10,, %Message%
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 0x41, Chrome is Open, Please close all instances of Chrome and then click OK to continue with replacing Chrome with the newest version.
IfMsgBox OK, {
} Else IfMsgBox Cancel, {
return
}
}
else,
break
}
; make sure all instances of chromedriver.exe are closed
Message = Checking and killing any instances of the chromedriver.exe process
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
Loop, 5 {
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")
return
; msgbox
}
FileGetTime, ChromeDriverExeOldCreationTime, %ChromeDriverProgramFilesExeFilepath%, C
Message = Downloading Chromedriver v%ChromeStableLatestVersion% to:`n%ChromeDriverDownloadZipFilepath%
Message = Downloading Chromedriver v%ChromeStableLatestVersion% `nFrom: %chromedriverDLURL64%`nTo: %ChromeDriverDownloadZipFilepath%
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
UrlDownloadToFile, %chromedriverDLURL64%, %ChromeDriverDownloadZipFilepath%
Message = Downloading Chromium v%ChromeStableLatestVersion% to:`n%ChromeDownloadZipFilepath%
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%
@ -132,6 +180,8 @@ DownloadLatestChromium(){
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%
@ -261,11 +311,11 @@ DownloadLatestChromium(){
ToolTip
return
}
}
CheckForChromeUpdates(ChromeFilepath := ""){
CheckForChromeUpdates(ChromeFilepath := ""){
if(ChromeFilepath = "")
ChromeFilepath := GetInstalledChromeFilepath()
@ -279,10 +329,10 @@ CheckForChromeUpdates(ChromeFilepath := ""){
else, Return 0
}
}
GetInstalledChromeFilepath(){
GetInstalledChromeFilepath(){
; ChromeFilepath is global variable
if(ChromeFilepath = ""){
@ -314,9 +364,9 @@ GetInstalledChromeFilepath(){
}
ToolTip
}
}
GetInstalledChromeVersion(){
GetInstalledChromeVersion(){
if(ChromeFilepath = ""){
GetInstalledChromeFilepath()
@ -329,10 +379,10 @@ GetInstalledChromeVersion(){
InstalledChromeVersion := StrReplace(InstalledChromeVersion, "`r") ; replace any newline characters that powershell returns
return InstalledChromeVersion
}
}
GetLatestChromeStableVersion(){
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")
@ -349,10 +399,10 @@ GetLatestChromeStableVersion(){
}
return ChromeStableLatestVersion
}
}
GetDownloadURLOfChromeAndDriver(InstalledChromeVersion){
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
@ -399,4 +449,4 @@ GetDownloadURLOfChromeAndDriver(InstalledChromeVersion){
URLS = %chromeDLURL64%||%chromedriverDLURL64%
return URLS
}
}
Loading…
Cancel
Save