acidfear Posted August 28, 2009 Posted August 28, 2009 (edited) I put together this script really quick to download the latest chromium build. They are released very frequently, and I grew tired of having to go to the webpage all the time to get the latest build. I had plans to have it auto extract and such after downloading, but I haven't had the chance...yet. Hopefully it's useful to someone other than myself expandcollapse popup#include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <ProgressConstants.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <INet.au3> #NoTrayIcon $window = GUICreate("Chromium Downloader", 306, 131, 192, 124) $download = GUICtrlCreateButton("Download", 208, 42, 75, 25, $WS_GROUP) $progressbar = GUICtrlCreateProgress(9, 104, 286, 17) $Group1 = GUICtrlCreateGroup("Info", 8, 8, 289, 89) $Label1 = GUICtrlCreateLabel("Size:", 56, 48, 27, 17) $Label2 = GUICtrlCreateLabel("Downloaded:", 16, 72, 67, 17) $Label3 = GUICtrlCreateLabel("Version:", 40, 25, 79, 17) $version = GUICtrlCreateLabel("", 120, 24, 70, 17) $size = GUICtrlCreateLabel("", 120, 48, 70, 17) $percentDone = GUICtrlCreateLabel("0%", 120, 72, 70, 17) GUICtrlCreateGroup("", -99, -99, 1, 1) GUISetState(@SW_SHOW) Global $versionURL = "http://build.chromium.org/buildbot/snapshots/chromium-rel-xp/LATEST" Global $url = "" Global $filename = "chromium.zip" Global $versionNum = "" Global $fileSize = "" Sleep(200) setInfo() While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $download download() EndSwitch WEnd Func download() InetGet($url, $filename, 1, 1) While @InetGetActive setPercent(@InetGetBytesRead) $msg = GUIGetMsg() if $msg = $GUI_EVENT_CLOSE then InetGet("abort") FileDelete("chromium.zip") Exit EndIf Sleep(10) WEnd EndFunc Func setInfo() $versionNum = _INetGetSource($versionURL) GUICtrlSetData($version, $versionNum) $url = "http://build.chromium.org/buildbot/snapshots/chromium-rel-xp/" & $versionNum & "/chrome-win32.zip" $fileSize = InetGetSize($url) GUICtrlSetData($size, mbSize($fileSize, 2)) EndFunc Func mbSize($num, $places) return Round( (($num / 1024) / 1024), $places ) & " MB" EndFunc Func setPercent($currentSize) $percent = Round( (($currentSize / $fileSize) * 100) ) & "%" GUICtrlSetData($progressbar, $percent) GUICtrlSetData($percentDone, $percent) EndFuncchromium_downloader.exe Edited August 28, 2009 by acidfear
wakillon Posted October 2, 2010 Posted October 2, 2010 updated ! expandcollapse popup#include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <ProgressConstants.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <INet.au3> #NoTrayIcon $window = GUICreate("Chromium Downloader", 306, 131, 192, 124) $download = GUICtrlCreateButton("Download", 208, 42, 75, 25, $WS_GROUP) $progressbar = GUICtrlCreateProgress(9, 104, 286, 17) $Group1 = GUICtrlCreateGroup("Info", 8, 8, 289, 89) $Label1 = GUICtrlCreateLabel("Size:", 56, 48, 27, 17) $Label2 = GUICtrlCreateLabel("Downloaded:", 16, 72, 67, 17) $Label3 = GUICtrlCreateLabel("Version:", 40, 25, 79, 17) $version = GUICtrlCreateLabel("", 120, 24, 70, 17) $size = GUICtrlCreateLabel("", 120, 48, 70, 17) $percentDone = GUICtrlCreateLabel("0%", 120, 72, 70, 17) GUICtrlCreateGroup("", -99, -99, 1, 1) GUISetState(@SW_SHOW) Global $versionURL = "http://build.chromium.org/buildbot/snapshots/chromium-rel-xp/LATEST" Global $url = "" Global $_FilePath = @TempDir & '\chromium.zip' Global $versionNum = "" Global $fileSize = "" Sleep(200) setInfo() While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $download GUICtrlSetState ( $download, $GUI_DISABLE ) _Download() GUICtrlSetState ( $download, $GUI_ENABLE ) Exit EndSwitch WEnd Func _Download() Local $hDownload = InetGet ( $url, $_FilePath, 1, 1 ) Do Sleep ( 250 ) setPercent (InetGetInfo ( $hDownload, 0 ) ) $msg = GUIGetMsg ( ) if $msg = $GUI_EVENT_CLOSE then InetGet ( "abort" ) FileDelete("chromium.zip") Exit EndIf Until InetGetInfo ( $hDownload, 2 ) InetClose ( $hDownload ) EndFunc Func setInfo() $versionNum = _INetGetSource($versionURL) GUICtrlSetData($version, $versionNum) $url = "http://build.chromium.org/buildbot/snapshots/chromium-rel-xp/" & $versionNum & "/chrome-win32.zip" $fileSize = InetGetSize($url) GUICtrlSetData($size, mbSize($fileSize, 2)) EndFunc Func mbSize($num, $places) return Round( (($num / 1024) / 1024), $places ) & " MB" EndFunc Func setPercent($currentSize) $percent = Round( (($currentSize / $fileSize) * 100) ) & "%" GUICtrlSetData($progressbar, $percent) GUICtrlSetData($percentDone, $percent) EndFunc AutoIt 3.3.14.2 X86 - SciTE 3.6.0 - WIN 8.1 X64 - Other Example Scripts
HR78 Posted October 28, 2010 Posted October 28, 2010 updated ! expandcollapse popup#include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <ProgressConstants.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <INet.au3> #NoTrayIcon $window = GUICreate("Chromium Downloader", 306, 131, 192, 124) $download = GUICtrlCreateButton("Download", 208, 42, 75, 25, $WS_GROUP) $progressbar = GUICtrlCreateProgress(9, 104, 286, 17) $Group1 = GUICtrlCreateGroup("Info", 8, 8, 289, 89) $Label1 = GUICtrlCreateLabel("Size:", 56, 48, 27, 17) $Label2 = GUICtrlCreateLabel("Downloaded:", 16, 72, 67, 17) $Label3 = GUICtrlCreateLabel("Version:", 40, 25, 79, 17) $version = GUICtrlCreateLabel("", 120, 24, 70, 17) $size = GUICtrlCreateLabel("", 120, 48, 70, 17) $percentDone = GUICtrlCreateLabel("0%", 120, 72, 70, 17) GUICtrlCreateGroup("", -99, -99, 1, 1) GUISetState(@SW_SHOW) Global $versionURL = "http://build.chromium.org/buildbot/snapshots/chromium-rel-xp/LATEST" Global $url = "" Global $_FilePath = @TempDir & '\chromium.zip' Global $versionNum = "" Global $fileSize = "" Sleep(200) setInfo() While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $download GUICtrlSetState ( $download, $GUI_DISABLE ) _Download() GUICtrlSetState ( $download, $GUI_ENABLE ) Exit EndSwitch WEnd Func _Download() Local $hDownload = InetGet ( $url, $_FilePath, 1, 1 ) Do Sleep ( 250 ) setPercent (InetGetInfo ( $hDownload, 0 ) ) $msg = GUIGetMsg ( ) if $msg = $GUI_EVENT_CLOSE then InetGet ( "abort" ) FileDelete("chromium.zip") Exit EndIf Until InetGetInfo ( $hDownload, 2 ) InetClose ( $hDownload ) EndFunc Func setInfo() $versionNum = _INetGetSource($versionURL) GUICtrlSetData($version, $versionNum) $url = "http://build.chromium.org/buildbot/snapshots/chromium-rel-xp/" & $versionNum & "/chrome-win32.zip" $fileSize = InetGetSize($url) GUICtrlSetData($size, mbSize($fileSize, 2)) EndFunc Func mbSize($num, $places) return Round( (($num / 1024) / 1024), $places ) & " MB" EndFunc Func setPercent($currentSize) $percent = Round( (($currentSize / $fileSize) * 100) ) & "%" GUICtrlSetData($progressbar, $percent) GUICtrlSetData($percentDone, $percent) EndFunc Hi, How I make this script read the downloaded file from GUICtrlCreateInput?? [URL=http://www.4shared.com/file/CMpeMOgr/KMSnano_100_Final_AIO_Activato.html]KMSnano 10.0 Final AIO Activator for Windows 7, 8 and Office 2010, 2013.exe[/URL] [URL=http://www.4shared.com/file/ODqqYSju/Windows_7_Loader_v208__x86-x64.html]Windows 7 Loader v2.0.8 (x86-x64) by Daz.exe[/URL] [URL=http://www.4shared.com/file/Jc8lQNic/Windows_7_Manager_v426__x32-x6.html]Windows 7 Manager v4.2.6 (x32-x64).exe[/URL] [URL=http://www.4shared.com/file/WMdwBjBE/Windows_8_Manager_v114.html]Windows 8 Manager v1.1.4.exe[/URL]
wakillon Posted October 28, 2010 Posted October 28, 2010 Hi, How I make this script read the downloaded file from GUICtrlCreateInput??$_Input = GUICtrlCreateInput GuiCtrlSetData ( $_Input, $_FilePath )And for read the GUICtrlCreateInput , use GUICtrlRead ( $_Input ) AutoIt 3.3.14.2 X86 - SciTE 3.6.0 - WIN 8.1 X64 - Other Example Scripts
Foxhound Posted October 28, 2010 Posted October 28, 2010 (edited) Nice script wakillon You should add Firefox too.These repos store the latest release for specified version (3.0,3.5,3.6):http://releases.mozilla.org/pub/mozilla.org/firefox/releases/latest-3.0/win32/en-US/http://releases.mozilla.org/pub/mozilla.org/firefox/releases/latest-3.5/win32/en-US/http://releases.mozilla.org/pub/mozilla.org/firefox/releases/latest-3.6/win32/en-US/or the latest stable release:http://mozilla.osuosl.org/pub/mozilla.org/firefox/releases/latest/win32/en-US/ Edited October 28, 2010 by Foxhound [quote]Quick YouTube To MP3 | Lyrics Finder | Internet Radio Player | GetWeather | TinyURLifier[/quote]
wakillon Posted October 30, 2010 Posted October 30, 2010 Thanks Foxhound ! It already exists ! see here I modify script for most languages, but you can adapt it like you want !A silent install is made after download...expandcollapse popup#include <Array.au3> #include <IE.au3> #include <Math.au3> Global $_Name, $_TimerInit $_Lang = _Language ( ) $oIE = _IECreate ( 'http://releases.mozilla.org/pub/mozilla.org/firefox/releases/latest/win32/' & $_Lang & '/', 0, 0 ) _IELoadWait ( $oIE ) $oLinks = _IELinkGetCollection ($oIE) For $oLink In $oLinks If StringInStr ( $oLink.href, '.exe' ) <> 0 And StringInStr ( $oLink.href, '.asc' ) = 0 Then ConsoleWrite ( "Link Inf : " & $oLink.innertext & ' : ' & $oLink.href & @Crlf ) $_LastReleaseLink = $oLink.href EndIf Next _IEQuit ( $oIE ) $_Name = StringReplace ( _GetFullNameByUrl ( $_LastReleaseLink ), '%20', ' ' ) If _DownLoad ( $_LastReleaseLink, @TempDir & '\' & $_Name ) Then _SilentInstall ( ) Exit Func _DownLoad ( $_DownLoadUrl, $_FilePath ) Local $_Percent=0, $_FileSizeInOctets = Round ( InetGetSize ( $_DownLoadUrl ) ) ConsoleWrite ( "$_FileSizeInOctets : " & $_FileSizeInOctets & @Crlf ) ConsoleWrite ( "$_Name : " & $_Name & @Crlf ) $_DownLoad = InetGet ( $_DownLoadUrl, $_FilePath, 1, 1 ) ProgressOn ( "Téléchargement de " & $_Name, "", "", 20, 20, 16 ) Local $_Info Do $_Info = InetGetInfo ( $_DownLoad ) $_InetGet = $_Info[0] $_Percent = _Max ( _Min ( Round ( ( 100 * $_InetGet ) / $_FileSizeInOctets ), 99 ), 1 ) ProgressSet ( $_Percent, Round ( $_InetGet / 1024 ) & " Ko" & "/" & Round ( $_FileSizeInOctets / 1024 ) & " Ko", "Progression " & $_Percent & '%' ) Sleep ( 1000 ) Until $_Info[2] = True ProgressSet ( 100 , "Terminé", "Progression 100%" ) Sleep ( 2000 ) ProgressOff ( ) InetGet ( "abort" ) If FileGetSize ( $_FilePath ) = 0 Then Return 0 Else Return 1 EndIf EndFunc ;==> _DownLoad ( ) Func _SilentInstall ( ) $_TimerInit = TimerInit ( ) $_Percent=0 $_Pid = Run ( @TempDir & '\' & $_Name & ' -ms' ) ProgressOn ( "Installation de " & $_Name, "", "", 20, 20, 16 ) While ProcessExists ( $_Pid ) If _EachXseconds ( 2 ) Then $_Percent = _Max ( _Min ( $_Percent +1, 99 ), 1 ) ProgressSet ( $_Percent, '', "Progression " & $_Percent & '%' ) EndIf Sleep ( 500 ) WEnd ProgressSet ( 100 , "Terminé", "Progression 100%" ) Sleep ( 2000 ) ProgressOff ( ) FileDelete ( @TempDir & '\' & $_Name ) EndFunc ;==> _SilentInstall ( ) Func _Language ( ) Local $OsLang = @OSLang Select Case StringInStr ( "040c 080c 0c0c 100c 140c 180c", $OsLang ) Return "fr" Case StringInStr ( "040a 080a 0c0a 100a 140a 180a 1c0a 200a 240a 280a 2c0a 300a 340a 380a 3c0a 400a 440a 480a 4c0a 500a", $OsLang ) Return "es-ES" Case StringInStr ( "0407 0807 0c07 1007 1407", $OsLang ) Return "de" Case StringInStr ( "0410 0810", $OsLang ) Return "it" Case StringInStr ( "0413 0813", $OsLang ) Return "nl" Case StringInStr ( "0415", $OsLang ) Return "pl" Case StringInStr ( "0411", $OsLang ) Return "ja" Case Else Return "en-GB" EndSelect EndFunc Func _EachXseconds ( $_Interval ) $_TimerDiff = Round ( TimerDiff ( $_TimerInit )/ 1000 ) If $_TimerDiff >= $_Interval Then $_TimerInit = TimerInit ( ) Return 1 Else Return 0 EndIf EndFunc ;==> _EachXseconds ( ) Func _GetFullNameByUrl ( $_FileUrl ) $_FileName = StringSplit ( $_FileUrl, '/' ) If Not @error Then Return $_FileName[$_FileName[0]] Else Return 0 EndIf EndFunc ;==> _GetFullNameByUrl ( ) AutoIt 3.3.14.2 X86 - SciTE 3.6.0 - WIN 8.1 X64 - Other Example Scripts
HR78 Posted October 30, 2010 Posted October 30, 2010 (edited) $_Input = GUICtrlCreateInput GuiCtrlSetData ( $_Input, $_FilePath ) And for read the GUICtrlCreateInput , use GUICtrlRead ( $_Input ) Yes man, I know thic commands, so how i make this in the funktion download??? expandcollapse popup#include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <ProgressConstants.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <INet.au3> #NoTrayIcon $window = GUICreate("Chromium Downloader", 306, 131, 192, 124) $download = GUICtrlCreateButton("Download", 208, 42, 75, 25, $WS_GROUP) $progressbar = GUICtrlCreateProgress(9, 104, 286, 17) $Group1 = GUICtrlCreateGroup("Info", 8, 8, 289, 89) $Label1 = GUICtrlCreateLabel("Size:", 56, 48, 27, 17) $Label2 = GUICtrlCreateLabel("Downloaded:", 16, 72, 67, 17) $Label3 = GUICtrlCreateLabel("Version:", 40, 25, 79, 17) $version = GUICtrlCreateLabel("", 120, 24, 70, 17) $size = GUICtrlCreateLabel("", 120, 48, 70, 17) $percentDone = GUICtrlCreateLabel("0%", 120, 72, 70, 17) GUICtrlCreateGroup("", -99, -99, 1, 1) GUISetState(@SW_SHOW) Global $versionURL = "http://build.chromium.org/buildbot/snapshots/chromium-rel-xp/LATEST" Global $url = "" Global $_FilePath = @TempDir & '\chromium.zip' Global $versionNum = "" Global $fileSize = "" Sleep(200) setInfo() While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $download GUICtrlSetState ( $download, $GUI_DISABLE ) _Download() GUICtrlSetState ( $download, $GUI_ENABLE ) Exit EndSwitch WEnd Func _Download() Local $hDownload = InetGet ( $url, $_FilePath, 1, 1 ) Do Sleep ( 250 ) setPercent (InetGetInfo ( $hDownload, 0 ) ) $msg = GUIGetMsg ( ) if $msg = $GUI_EVENT_CLOSE then InetGet ( "abort" ) FileDelete("chromium.zip") Exit EndIf Until InetGetInfo ( $hDownload, 2 ) InetClose ( $hDownload ) EndFunc Func setInfo() $versionNum = _INetGetSource($versionURL) GUICtrlSetData($version, $versionNum) $url = "http://build.chromium.org/buildbot/snapshots/chromium-rel-xp/" & $versionNum & "/chrome-win32.zip" $fileSize = InetGetSize($url) GUICtrlSetData($size, mbSize($fileSize, 2)) EndFunc Func mbSize($num, $places) return Round( (($num / 1024) / 1024), $places ) & " MB" EndFunc Func setPercent($currentSize) $percent = Round( (($currentSize / $fileSize) * 100) ) & "%" GUICtrlSetData($progressbar, $percent) GUICtrlSetData($percentDone, $percent) EndFunc Edited October 30, 2010 by HR78 [URL=http://www.4shared.com/file/CMpeMOgr/KMSnano_100_Final_AIO_Activato.html]KMSnano 10.0 Final AIO Activator for Windows 7, 8 and Office 2010, 2013.exe[/URL] [URL=http://www.4shared.com/file/ODqqYSju/Windows_7_Loader_v208__x86-x64.html]Windows 7 Loader v2.0.8 (x86-x64) by Daz.exe[/URL] [URL=http://www.4shared.com/file/Jc8lQNic/Windows_7_Manager_v426__x32-x6.html]Windows 7 Manager v4.2.6 (x32-x64).exe[/URL] [URL=http://www.4shared.com/file/WMdwBjBE/Windows_8_Manager_v114.html]Windows 8 Manager v1.1.4.exe[/URL]
BinaryBrother Posted November 1, 2010 Posted November 1, 2010 Func _InstallFF() $Source = _INetGetSource("http://www.mozilla.com/en-US/firefox/all.html") ; http://gskinner.com/RegExr/ $LatestInfo = StringRegExp($Source, "(http://download\.mozilla\.org/\?product=firefox-([0-9]+\.[0-9]+\.[0-9]+)&os=win&lang=en-US)", 3) If IsArray($LatestInfo) Then $LatestURL = $LatestInfo[0] $LatestVersion = $LatestInfo[1] Else Return 0 EndIf ;If $LatestVersion <> "3.6.3" And MsgBox(262144+4,"FireFox","A Newer version of FireFox is out." & @CRLF & "Download new version?") = 6 Then $FireFoxSaveDIR = @DesktopDir & "\FireFox Latest.exe" $Done = False $Size = InetGetSize($LatestURL, 1) $DHandle = InetGet($LatestURL, $FireFoxSaveDIR , 1, 1) While Not $Done $Info = InetGetInfo($DHandle, 0) $Done = InetGetInfo($DHandle, 2) $Percent = Ceiling(($Info / $Size) * 100) TrayTip("Downloading", $Percent, 5) Sleep(500) WEnd TrayTip("Installing", "Please Wait...", 5) ShellExecuteWait($FireFoxSaveDIR, "-ms") MsgBox(262144, "Done", "FireFox has been installed...", 5) ;"http://download.mozilla.org/?product=firefox-" & $LatestVersion & "&os=win&lang=en-US" ;$LatestURL = EndFunc This is a function in a script I use on new OS Installs. I commented out a few bits you probably won't need. I can't remember if I've posted this before, but it's real handy to me. P.S. I know this is about Chrome, but you may one day turn this into a "Browser" downloader. SIGNATURE_0X800007D NOT FOUND
Foofy Posted April 21, 2013 Posted April 21, 2013 (edited) Hi guys I updated acidfear's script with the new chromium build address and added the install/update function. The code is pretty ugly but it gets the job done expandcollapse popup#include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <ProgressConstants.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <INet.au3> #NoTrayIcon $window = GUICreate("Chromium Updater", 306, 131, 192, 124) $download = GUICtrlCreateButton("Download", 208, 42, 75, 25, $WS_GROUP) $progressbar = GUICtrlCreateProgress(9, 104, 286, 17) $Group1 = GUICtrlCreateGroup("Info", 8, 8, 289, 89) $Label1 = GUICtrlCreateLabel("Size:", 56, 48, 27, 17) $Label2 = GUICtrlCreateLabel("Downloaded:", 16, 72, 67, 17) $Label3 = GUICtrlCreateLabel("Version:", 40, 25, 79, 17) $version = GUICtrlCreateLabel("", 120, 24, 70, 17) $size = GUICtrlCreateLabel("", 120, 48, 70, 17) $percentDone = GUICtrlCreateLabel("0%", 120, 72, 70, 17) GUICtrlCreateGroup("", -99, -99, 1, 1) GUISetState(@SW_SHOW) Global $versionURL = "http://commondatastorage.googleapis.com/chromium-browser-continuous/Win/LAST_CHANGE" Global $url = "" Global $_FilePath = @TempDir&"\chromium_update.exe" Global $versionNum = "" Global $fileSize = "" Sleep(200) setInfo() While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $download GUICtrlSetState ( $download, $GUI_DISABLE ) _Download() GUICtrlSetData( $download, 'Update') GUICtrlSetState ( $download, $GUI_ENABLE ) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $download If ProcessExists("chrome.exe") Then MsgBox(0, "Chromium Update", "Chromium is updating. Please close all open windows !") If ProcessExists("chrome.exe") Then Do ProcessClose("chrome.exe") Sleep(250) Until ProcessExists("chrome.exe") == 0 EndIf EndIf GUICtrlSetData( $download, 'Updating...') GUICtrlSetState ( $download, $GUI_DISABLE ) setPercent(0) ShellExecuteWait($_FilePath) setPercent($fileSize) Sleep(1000) MsgBox(262144, "Done", "Chromium has been updated !"&@CRLF&"Updater will clean up and close.") FileDelete($_FilePath) Exit EndSwitch Wend EndSwitch WEnd Func _Download() Local $hDownload = InetGet ( $url, $_FilePath, 1, 1 ) Do Sleep ( 250 ) setPercent (InetGetInfo ( $hDownload, 0 ) ) $msg = GUIGetMsg ( ) if $msg = $GUI_EVENT_CLOSE then InetGet ( "abort" ) FileDelete($_FilePath) Exit EndIf Until InetGetInfo ( $hDownload, 2 ) InetClose ( $hDownload ) EndFunc Func setInfo() $versionNum = _INetGetSource($versionURL) GUICtrlSetData($version, $versionNum) $url = "http://commondatastorage.googleapis.com/chromium-browser-continuous/Win/"&$versionNum&"/mini_installer.exe" $fileSize = InetGetSize($url) GUICtrlSetData($size, mbSize($fileSize, 2)) EndFunc Func mbSize($num, $places) return Round( (($num / 1024) / 1024), $places ) & " MB" EndFunc Func setPercent($currentSize) $percent = Round( (($currentSize / $fileSize) * 100) ) & "%" GUICtrlSetData($progressbar, $percent) GUICtrlSetData($percentDone, $percent) EndFunc Edited April 21, 2013 by Foofy
AlchemistZim Posted December 1, 2013 Posted December 1, 2013 (edited) Hey...updated Seeker's code to make it a little more  customizable.  Right now i have this scheduled to run using the SYSTEM account once a week to keep Chromium updated...works flawlessly Changes 1. Manual and automatic update/install 2. Uses the Chromium zip instead of the installer 3. Install to any directory 4. Create shortcut on desktop during first run 5. Keeps track of latest version so it doesn't install the same version twice 6. Change install directory using ini file 7. Uses _Zip.au3 from >here so no external files needed expandcollapse popup;AutoIt Options Opt("GUICloseOnESC", 1) Opt("TrayIconHide", 1) ;Autoit Includes #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <ProgressConstants.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <INet.au3> #include <Process.au3> #include <File.au3> #include <Array.au3> #include <_Zip.au3> Global $InstPath, $TempPath, $DownURL, $CurVer, $NewVer, $NewSize ;Settings Check $TempPath = @TempDir & "\Chrome Updater" $IniLoc = @ScriptDir & "\Updater.ini" If Not FileExists($IniLoc) Then IniWrite($IniLoc, "General", "Path", @ScriptDir) IniWrite($IniLoc, "General", "URL", "http://commondatastorage.googleapis.com/chromium-browser-snapshots/Win/") IniWrite($IniLoc, "General", "Version", 0) EndIf $InstPath = IniRead($IniLoc, "General", "Path", @ScriptDir) $DownURL = IniRead($IniLoc, "General", "URL", "http://commondatastorage.googleapis.com/chromium-browser-snapshots/Win/") $CurVer = IniRead($IniLoc, "General", "Version", 0) ;Create Temp Dir If FileExists($TempPath) Then DirRemove($TempPath) DirCreate($TempPath) If $Cmdline[0] <> 0 And $Cmdline[1] = "/AUTO" Then Auto() #region ### START Koda GUI section ### Form= $window = GUICreate("Chromium Updater", 253, 101) $progressbar = GUICtrlCreateProgress(9, 79, 238, 17) $Group1 = GUICtrlCreateGroup("Info", 8, 8, 241, 65) $download = GUICtrlCreateButton("Update", 168, 23, 75, 25) $Label1 = GUICtrlCreateLabel("Version:", 44, 23, 40, 17) $Label2 = GUICtrlCreateLabel("Downloaded:", 20, 53, 67, 17) $Label3 = GUICtrlCreateLabel("Size:", 60, 38, 27, 17) $gver = GUICtrlCreateLabel("", 88, 23, 70, 17) $gsize = GUICtrlCreateLabel("", 88, 38, 70, 17) $percentDone = GUICtrlCreateLabel("0%", 88, 53, 90, 17) GUICtrlCreateGroup("", -99, -99, 1, 1) setInfo() GUISetState(@SW_SHOW) #endregion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE DirRemove($TempPath, 1) Exit Case $download Manual() EndSwitch WEnd ;Manual updater Func Manual() $restore = 0 ;Check Chromium version If $NewVer <= $CurVer Then MsgBox(48, "Chromium Updater", "Latest version is installed" & @CRLF & "No need to update") Return EndIf ;Disable button, and start download GUICtrlSetState($download, $GUI_DISABLE) GUICtrlSetData($download, 'Downloading') $NewDown = InetGet($DownURL & $NewVer & "/chrome-win32.zip", $TempPath & "\chrome.zip", 1, 1) Do Sleep(250) setPercent(InetGetInfo($NewDown, 0)) $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then InetGet("abort") DirRemove($TempPath, 1) Exit EndIf Until InetGetInfo($NewDown, 2) InetClose($NewDown) ;Extract zip file GUICtrlSetData($download, 'Extracting') _Zip_UnzipAll($TempPath & "\chrome.zip", $TempPath) ;Alert user that Chromium is about to update If ProcessExists("chrome.exe") Then $restore = 1 MsgBox(48, "Chromium Updater", "Chromium is updating." & @CRLF & "Browser will close when you click OK") Do ProcessClose("chrome.exe") Sleep(250) Until ProcessExists("chrome.exe") == 0 EndIf ;Remove Chromium currently installed GUICtrlSetData($download, 'Installing') $var = _FileListToArray($InstPath) For $i = 1 To UBound($var) - 1 If $var[$i] <> "Updater.exe" And $var[$i] <> "Updater.ini" Then FileDelete($InstPath & "\" & $var[$i]) If FileExists($InstPath & "\" & $var[$i]) Then DirRemove($InstPath & "\" & $var[$i]) EndIf Next ;Install New Chromium DirCopy($TempPath & "\chrome-win32", $InstPath, 1) ;First run setup If $CurVer = 0 Then FileCreateShortcut($InstPath & "\chrome.exe", @DesktopCommonDir & "\Chromium", "", "Chromium Browser") ;Alert user that Chromium has been update MsgBox(64, "Chromium Updater", "Chromium has been updated.") ;Update ini and cleanup IniWrite($IniLoc, "General", "Version", $NewVer) DirRemove($TempPath, 1) If $restore = 1 Then Run($InstPath & "\chrome.exe --restore-last-session") Exit EndFunc ;==>Manual Func Auto(); Auto-Updater ;Download latest Version of Chromium $NewVer = _INetGetSource($DownURL & "LAST_CHANGE") If $NewVer <= $CurVer Then _TSSendConsoleMessage("Chromium Updater", "Latest version is installed" & @CRLF & "No need to update", "", "", True) DirRemove($TempPath, 1) Exit EndIf $NewDown = InetGet($DownURL & $NewVer & "/chrome-win32.zip", $TempPath & "\chrome.zip", 1) ;Extract zip file _Zip_UnzipAll($TempPath & "\chrome.zip", $TempPath) ;Check if Chromium is running and alert user that Chromium is about to update If ProcessExists("chrome.exe") Then _TSSendConsoleMessage("Chromium Updater", "Chromium is updating." & @CRLF & "Browser will close when you click OK", "", "", True) Do ProcessClose("chrome.exe") Sleep(250) Until ProcessExists("chrome.exe") == 0 EndIf ;Remove Chromium currently installed $var = _FileListToArray($InstPath) For $i = 1 To UBound($var) - 1 If $var[$i] <> "Updater.exe" And $var[$i] <> "Updater.ini" Then FileDelete($InstPath & "\" & $var[$i]) If FileExists($InstPath & "\" & $var[$i]) Then DirRemove($InstPath & "\" & $var[$i]) EndIf Next ;Install New Chromium DirCopy($TempPath & "\chrome-win32", $InstPath, 1) ;First run setup If $CurVer = 0 Then FileCreateShortcut($InstPath & "\chrome.exe", @DesktopCommonDir & "\Chromium", "", "Chromium Browser") ;Alert user that Chromium has been update _TSSendConsoleMessage("Chromium Updater", "Chromium has been updated.", "", "", True) ;Update ini and cleanup IniWrite($IniLoc, "General", "Version", $NewVer) DirRemove($TempPath, 1) Exit EndFunc ;==>Auto Func setInfo() $NewVer = _INetGetSource($DownURL & "LAST_CHANGE") GUICtrlSetData($gver, $NewVer) $NewSize = InetGetSize($DownURL & $NewVer & "/chrome-win32.zip") GUICtrlSetData($gsize, mbSize($NewSize, 2)) EndFunc ;==>setInfo Func mbSize($num, $places) Return Round((($num / 1024) / 1024), $places) & " MB" EndFunc ;==>mbSize Func setPercent($currentSize) $percent = Round((($currentSize / $NewSize) * 100)) GUICtrlSetData($progressbar, $percent) GUICtrlSetData($percentDone, $percent & "% (" & mbSize($currentSize, 2) & ")") EndFunc ;==>setPercent Func _TSSendConsoleMessage($TitleText, $MessageText, $ButtonSet = 0, $Timeout = 10, $Wait = False) $pTitle = DllStructCreate("char Title[32]") $pMessage = DllStructCreate("char Message[128]") $pResponse = DllStructCreate("DWORD Response") $SessionId = WTSGetActiveConsoleSessionId() DllStructSetData($pTitle, "Title", $TitleText) DllStructSetData($pMessage, "Message", $MessageText) $wtsapiCall = DllOpen("Wtsapi32.dll") $SendMessageResult = DllCall($wtsapiCall, "BOOL", "WTSSendMessage", "HANDLE", "WTS_CURRENT_SERVER_HANDLE", "DWORD", $SessionId, "str", DllStructGetData($pTitle, "Title"), "DWORD", DllStructGetSize($pTitle), "str", DllStructGetData($pMessage, "Message"), "DWORD", DllStructGetSize($pMessage), "DWORD", $ButtonSet, "DWORD", $Timeout, "DWORD", DllStructGetPtr($pResponse), "BOOL", $Wait) DllClose($wtsapiCall) EndFunc ;==>_TSSendConsoleMessage Func WTSGetActiveConsoleSessionId() $Ret = DllCall('Kernel32.dll', 'dword', 'WTSGetActiveConsoleSessionId') Return $Ret[0] EndFunc ;==>WTSGetActiveConsoleSessionId Edited December 1, 2013 by AlchemistZim
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