emmanuel Posted June 22, 2004 Share Posted June 22, 2004 (edited) prompted by bobheart's plee for help, I've created the AutoIt AutoUpdater(autoit, automating autoit's install, very fitting.) Since it reinstalls autoit, you have to run it compiled.You can run it with a filename following it and it will use that as an INI file to fulfil it's settings... Run it without a filename, or with a filename that doesn't exist and it will create a new INI with the prompted input.expandcollapse popup;download and update latest unstable of autoit ;the first time you run it, it'll ask for your preferences. ;AutoItSetOption("TrayIconDebug",1) if not @Compiled then MsgBox(0,"Autosetup Autoit", "Must run compiled, or files will not be properly installed") Exit EndIf #region cmd line options If $cmdline[0] = 1 Then if ($cmdline[1] = "/h") or ($cmdline[1] = "/?") Then MsgBox(0, "Auto Update AutoIt", "Download and install latest unstable build of Autoit." & @LF & _ "Settings are kept in INI files, you can specify a new INI file or different INI files by putting that on the command line after this script." & @LF & _ "Default INI is Update.ini" & @LF & "Example:" & @TAB & "update autoit.exe new.ini" & @LF & "If the file doesn't exist, you will be prompted with the questions that build the file, if it does exist, the settings in the file will be used.") EndIf If $cmdline[1] <> "/h" Or $cmdline[1] <> "/?" Then $ini = $cmdline[1] EndIf Else $ini = @ScriptDir & "\update.ini" EndIf #endregion cmd line options #region settings If FileExists($ini) = 0 Then $au3version = InputBox("AutoIt Version", "This is the version name as it appears throughout the setup program,"&@LF& _ "If the script doesn't complete, you may need to change this.","AutoIt v3.0.102") If @error = 1 Then Exit EndIf $download = InputBox("AUTOIT URL", "Paste the URL for the autoitunstable url that you'd like to download." & @LF & _ "(include the http://)", "http://www.autoitscript.com/autoit3/files/unstable/autoit/autoit-v3.0.102.exe") If @error = 1 Then Exit EndIf $targetfolder = FileSelectFolder("Target directory for Autoit download", "", 1) If @error = 1 Then Exit EndIf $installdir = FileSelectFolder("Directory to install Autoit in", "", 1) If @error = 1 Then Exit EndIf If MsgBox(4, "Overwrite previous version?", "Do you prefer to overwrite the previous version, or install fresh?" & @LF & "Yes to Overwrite and keep your settings") = 6 Then $overwrite = 1 Else $overwrite = 0 EndIf If InputBox("License Agreenment", "Do you promise to read the license agreement and be a good kid?" & @LF & " Type AGREE to continue (CAPS matter)") == "AGREE" Then If @error = 1 Then Exit EndIf $agree = 1 Else Exit EndIf if MsgBox(4, "Scite?","Update Scite at the same time?") = 6 Then $updatescite=1 Else $updatescite=0 EndIf IniWrite($ini, "NET", "download", $download) IniWrite($ini, "LOCAL", "installdir", $installdir) IniWrite($ini, "LOCAL", "folder", $targetfolder) IniWrite($ini, "LEGAL", "agree", $agree) IniWrite($ini, "PREFS", "overwrite", $overwrite) IniWrite($ini, "PREFS", "au3version", $au3version) IniWrite($ini, "PREFS", "updatescite", $updatescite) Else $overwrite = IniRead($ini, "PREFS", "overwrite", 1) $installdir = IniRead($ini, "LOCAL", "installdir", @ProgramFilesDir & "\AutoIt3") $targetfolder = IniRead($ini, "LOCAL", "folder", @TempDir) $download = IniRead($ini, "NET", "download", "http://www.autoitscript.com/autoit3/files/unstable/autoit/autoit-v3.0.102.exe") $agree = IniRead($ini, "LEGAL", "agree", 0) $au3version = IniRead($ini, "PREFS", "au3version", "AutoIt v3.0.102" ) $updatescite= IniRead($ini, "PREFS", "updatescite",0) ProgressOn("AutoIt Updater", "Installing "& $au3version) EndIf #endregion settings #region setup $filename = $targetfolder & "\" & StringTrimLeft($download, StringInStr($download, "/", 0, -1)) ;MsgBox(0,"URL to filename",$download & " to " & $filename) ;SplashTextOn("Autoit Updater", "Downloading " & $download & " to " & $filename, 600, 100, -1, -1, 1 + 2 + 16) if WinExists($au3version & " Setup") Then ProgressOff() MsgBox(0,"Setup detected", "Auto installer detects another setup window open" & @LF & "Make sure Setup isn't already running and try again.") Exit EndIf ProgressSet(5, "Downloading " & $download & " to " & $filename) If URLDownloadToFile($download & "?fakeparam=" & int(random(500)), $filename) = 0 Then ProgressOff() ;SplashOff() MsgBox(0, "ERROR", "Error downloading file, check your URL:" & @LF & $download) Exit EndIf ;I could just do a /S to do a silent install, but that sounds too easy. unless there's command line options for the setup's options, like file defualts and overwriting the current install? ;SplashOff() ProgressSet(15, "Running "& $filename) Run($filename) WinWait($au3version & " Setup", "Welcome to the AutoIt v3.0.102 Setup Wizard") ProgressSet(20, "Automating setup") ControlClick( $au3version & " Setup", "Welcome to the AutoIt v3.0.102 Setup Wizard","Button2") WinWait($au3version & " Setup", "License Agreement") if $agree == 1 then;you're ok Joe ProgressSet(25, "Automating setup") ControlClick($au3version & " Setup", "License Agreement", "Button2") Else ControlClick($au3version & " Setup", "License Agreement", "Button3") SplashOff() MsgBox(0, "License Error", "you didn't agree.") WinWait($au3version & " Setup","Are you sure you want to quit AutoIt v3.0.102 Setup?") ControlClick($au3version & " Setup","Are you sure you want to quit AutoIt v3.0.102 Setup?","Button1") Exit EndIf ProgressSet(25, "Automating setup") if WinWait($au3version & " Setup", "Please choose how you want to proceed.",5) = 1 Then ControlCommand($au3version & " Setup", "Please choose how you want to proceed.", "Button"&$overwrite + 4, "Check","") ControlClick($au3version & " Setup", "Please choose how you want to proceed.", "Button2") EndIf WinWait($au3version & " Setup", "Choose Install Location") ProgressSet(30, "Automating setup") ControlSetText($au3version & " Setup", "Choose Install Location","Edit1",$installdir) ControlClick($au3version & " Setup", "Choose Install Location","Button2") WinWait($au3version & " Setup", "AutoIt v3.0.102 has been installed on your computer.") ProgressSet(35, "Automating setup") ;ControlCommand($au3version & " Setup", "AutoIt v3.0.102 has been installed on your computer.", "Button4", "unCheck","");uncomment to avoid helpfile. ControlClick($au3version & " Setup", "AutoIt v3.0.102 has been installed on your computer.", "Button2") ProgressSet(100, "Automating setup") #endregion setup #region scite setup if $updatescite=1 Then sciteupdate() EndIf func sciteupdate() getfile('scite4autoit3.exe') Run(@ScriptDir & "\scite4autoit3.exe /S") EndFunc Func GetFile($FILE) SplashTextOn("Getting Beta files", $FILE, 200, 100) URLDownloadToFile("http://www.autoitscript.com/fileman/users/jdeb/" & $FILE & "?fakeparam=" & int(random(500)), @ScriptDir & "\" & $FILE) EndFunc;==>GetFile #endregionUpdated, it now supports a fresh install, so, you could run the compiled version, with INI file on a machine that's never had autoit and it should work. Edited June 25, 2004 by emmanuel "I'm not even supposed to be here today!" -Dante (Hicks) Link to comment Share on other sites More sharing options...
Valik Posted June 22, 2004 Share Posted June 22, 2004 Oooh, somebody else who uses #Region/#EndRegion. Link to comment Share on other sites More sharing options...
emmanuel Posted June 22, 2004 Author Share Posted June 22, 2004 Oooh, somebody else who uses #Region/#EndRegion.I just knew that would make someone happy! I read about it in the sciTE helpfile the other day and thought "nifty!" and have used it ever since. handy for getting big chunks of code out of view when not needed. "I'm not even supposed to be here today!" -Dante (Hicks) Link to comment Share on other sites More sharing options...
bobheart Posted June 22, 2004 Share Posted June 22, 2004 Work great the first time . how offen would this needed to be run ? I would love to be able to do this like you guys . but I sit here and i lok at the code and read part of it look to the screen and forget have of what I had just read .. So I have to copy and paste things or I can't remember what goes where.. grrrrr Man this sucks .. but thank you for making this . Link to comment Share on other sites More sharing options...
pekster Posted June 22, 2004 Share Posted June 22, 2004 I just knew that would make someone happy! I read about it in the sciTE helpfile the other day and thought "nifty!" and have used it ever since. handy for getting big chunks of code out of view when not needed.Code folding rocks. I've been using it forever in VIM (multi-platform text editor and syntax program.) Although ideally, the program would automatically allow you to fold code. Side note: KWord in KDE 3.2 now supports that by default. Yay!@bobheart: How about writing your code in pieces. First, define your main script with a few functions that do what you want. Then, define those functions. It's a "top down" programming approach, because you basically define the code you're writing in terms of functions that haven't yet been written. Then, you go and write them. Just an idea that might help you out if writing an entire script at once is hard for you. I use it myself all the time with larger projects because it lets me get the big picture before I work really hard on parts of code I don't actually end up using. [font="Optima"]"Standing in the rain, twisted and insane, we are holding onto nothing.Feeling every breath, holding no regrets, we're still looking out for something."[/font]Note: my projects are off-line until I can spend more time to make them compatable with syntax changes. Link to comment Share on other sites More sharing options...
emmanuel Posted June 22, 2004 Author Share Posted June 22, 2004 Work great the first time . how offen would this needed to be run ? I would love to be able to do this like you guys . but I sit here and i lok at the code and read part of it look to the screen and forget have of what I had just read .. So I have to copy and paste things or I can't remember what goes where.. grrrrr Man this sucks .. but thank you for making this .well, I wanted it myself. I think I just needed to know that other people might want it too. Add in a dash of "I just learned how to use INI files" and there you go. How often would you run this? As often as Jon posts in the Development forum that unstable has been updated. or as regularly as you feel you need. After running it the first time, it's silent, so you could schedule it or something. "I'm not even supposed to be here today!" -Dante (Hicks) Link to comment Share on other sites More sharing options...
bobheart Posted June 22, 2004 Share Posted June 22, 2004 Well the one code that I think you are someone did for me (I forget now sorry) I was able to use it for something else with a little help If i can get the grasp of a little of it I can learn where what goes where .etc. Ok I know what it was the url grabber I changed it to search drives and let you enter the drive letter (someone helped me with it ) . but i was able to use it for something else and gasp a little of what it was doing . Last year this would of been a cakewalk but now it is getting hander everyday . Thanks for everyones help . Link to comment Share on other sites More sharing options...
tutor2000 Posted June 22, 2004 Share Posted June 22, 2004 Work great the first time . how offen would this needed to be run ? I would love to be able to do this like you guys . but I sit here and i lok at the code and read part of it look to the screen and forget have of what I had just read .. So I have to copy and paste things or I can't remember what goes where.. grrrrr Man this sucks .. but thank you for making this .I copy and paste from examples and from the help file for what seems forever till I can do something new on my ownYou're learning the right way keep up the good workRick Link to comment Share on other sites More sharing options...
Guest Doxie Posted June 22, 2004 Share Posted June 22, 2004 Very simply version of the same function Remember to compile it before running, otherwise it will not work. Global $SD = @ScriptDir & "\" Global $config = $SD & "config.ini" Global $url = "http://www.autoitscript.com/autoit3/files/unstable/autoit/" Global $file = IniRead($config, "File", "Version", $url & "autoit-v3.0.102.exe") URLDownloadToFile($file, $SD & "autoit.exe") sleep (1000) ;depends on the speed from your ISP Run($SD & "autoit.exe") WinWaitActive("AutoIt v3.0.102") Send("{ENTER}") Send("{ENTER}") Send("{DOWN}") Send("{ENTER}") Send("{ENTER}") WinWait("AutoIt v3.0.102", "AutoIt v3.0.102 has been installed on your computer.") Send("{SPACE}") Send("{ENTER}") WinWaitClose("AutoIt v3.0.102") sleep(3000) FileDelete($SD & "autoit.exe") Link to comment Share on other sites More sharing options...
tuape Posted June 22, 2004 Share Posted June 22, 2004 What if version is something other than 3.0.102?? That will be the case sooner or later... Tuape Link to comment Share on other sites More sharing options...
Valik Posted June 22, 2004 Share Posted June 22, 2004 Why run the GUI? Use the /S option to install it silently. Link to comment Share on other sites More sharing options...
emmanuel Posted June 22, 2004 Author Share Posted June 22, 2004 Why run the GUI? Use the /S option to install it silently.I don't know if the /S overwrites or not, I'd rather it does, but I wanted to make something versitile and complete, not quick... yeah, after I was done, I thought, why didn't I just do that in five lines like Valik said? and it's because I want it to be customizable. It's just as much practice with string work and ini work as a handy way to update autoit. "I'm not even supposed to be here today!" -Dante (Hicks) Link to comment Share on other sites More sharing options...
emmanuel Posted June 22, 2004 Author Share Posted June 22, 2004 Very simply version of the same function Remember to compile it before running, otherwise it will not work. Global $SD = @ScriptDir & "\" Global $config = $SD & "config.ini" Global $url = "http://www.autoitscript.com/autoit3/files/unstable/autoit/" Global $file = IniRead($config, "File", "Version", $url & "autoit-v3.0.102.exe")URLDownloadToFile($file, $SD & "autoit.exe")sleep (1000) ;depends on the speed from your ISPRun($SD & "autoit.exe")WinWaitActive("AutoIt v3.0.102")Send("{ENTER}")Send("{ENTER}")Send("{DOWN}")Send("{ENTER}")Send("{ENTER}")WinWait("AutoIt v3.0.102", "AutoIt v3.0.102 has been installed on your computer.")Send("{SPACE}")Send("{ENTER}")WinWaitClose("AutoIt v3.0.102")sleep(3000)FileDelete($SD & "autoit.exe")the things I'm taking from writing this script are error checking, pulling and writing to an INI, oh, and the other part I really liked was really tricking IE into downloading a file each time. it'll never use the cache... also checking for the window's existance to make sure I wouldn't run two setups at once... errorchecking is cool.. and having it work on future versions of autoit, etcetera.I could have done this in 3-5 lines if I'd wanted, but it wouldn't have had all the errorchecking and future flexability. "I'm not even supposed to be here today!" -Dante (Hicks) Link to comment Share on other sites More sharing options...
Nutster Posted June 22, 2004 Share Posted June 22, 2004 Oooh, somebody else who uses #Region/#EndRegion.#Region is not in the AutoIt docs. What does this do? How to use it? When will it be in the docs? David NuttallNuttall Computer Consulting An Aquarius born during the Age of Aquarius AutoIt allows me to re-invent the wheel so much faster. I'm off to write a wizard, a wonderful wizard of odd... Link to comment Share on other sites More sharing options...
Valik Posted June 22, 2004 Share Posted June 22, 2004 #Region is not in the AutoIt docs. What does this do? How to use it? When will it be in the docs?It's not a part of Autoit. In every editor except SciTE, it will do absolutely nothing. It is exploiting a loophole in the way AutoIt parses lines starting with #. AutoIt completely ignores it and doesn't throw an error (The same holds true with anything starting with #). In SciTE, though, it behaves identical to the C# pre-processor commands of the same name which start and end a fold point in the IDE. It allows us who use SciTE to manually set up our own code folding points in addition to the fold points the lexer automatically creates. Link to comment Share on other sites More sharing options...
Developers Jos Posted June 22, 2004 Developers Share Posted June 22, 2004 (edited) Its part of the helpfile i created and is included in the Scite installset.... Have a look at the lexer features... Edited June 22, 2004 by JdeB SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
emmanuel Posted June 22, 2004 Author Share Posted June 22, 2004 oh, and the next step of this project will be the scite dl and auto installer... you know, probably about the next time you update it and I want to update mine. "I'm not even supposed to be here today!" -Dante (Hicks) Link to comment Share on other sites More sharing options...
Guest Guest Posted June 22, 2004 Share Posted June 22, 2004 the things I'm taking from writing this script are error checking, pulling and writing to an INI, oh, and the other part I really liked was really tricking IE into downloading a file each time. it'll never use the cache... also checking for the window's existance to make sure I wouldn't run two setups at once... errorchecking is cool.. and having it work on future versions of autoit, etcetera.I could have done this in 3-5 lines if I'd wanted, but it wouldn't have had all the errorchecking and future flexability.:iamstupid: 3 days of AutoIt, i belive i did pretty well. Of course you could make a input box and ask for the latest version etc. But i just thought it was fun to make one simple code that just download and install the current version. oh it works You did a very good job, i learned alot by reading your code, thanks.Also that you made a comment about my code is nice, but i belive you could spare me the sarcasm. Maybe i forgot to mention in that post that i'm new with AutoIt?But with a code like that i maybe thought it was unessesary.Anyway, keep up the good work... Link to comment Share on other sites More sharing options...
emmanuel Posted June 22, 2004 Author Share Posted June 22, 2004 (edited) :iamstupid: 3 days of AutoIt, i belive i did pretty well. Of course you could make a input box and ask for the latest version etc. But i just thought it was fun to make one simple code that just download and install the current version. oh it works More power to ya, it sure feels good to make something that works, huh?You did a very good job, i learned alot by reading your code, thanks.Thank you, good to hear that it's working for people.Also that you made a comment about my code is nice, but i belive you could spare me the sarcasm. Maybe i forgot to mention in that post that i'm new with AutoIt?But with a code like that i maybe thought it was unessesary.I didn't recall the sarcasm (when I'm sarcastic, I'm usually pretty happy with it, and remember) so I looked back through and don't see any such comment. Your script looks like one that I'd have written two months ago, maybe even better. I still remember what it's like to be a newb (how have I posted so much? I'm still a newb, there's so much I don't understand) anyway, I never slighted you , so don't be offended. Anyway, keep up the good work...Keep going, you'll get it, glad you were able to learn by reading my code.Edit: should have hit preview, not post, just reorganized things.... Edited June 22, 2004 by emmanuel "I'm not even supposed to be here today!" -Dante (Hicks) Link to comment Share on other sites More sharing options...
Developers Jos Posted June 22, 2004 Developers Share Posted June 22, 2004 (edited) Here are my 2 cent on this subject: I never download the BETA/Unstable installset because i believe you should always run the last production version and test with the BETA version from another directory. here's the script i use for downloading, which is located in the Autoit3Beta directory: ;download latest unstable GetFile('AutoIt.chm') GetFile('AutoIt3.exe') GetFile('AutoItSC.bin') Func GetFile($FILE) SplashTextOn("Getting Beta files", $FILE, 200, 100) URLDownloadToFile("http://www.autoitscript.com/autoit3/files/unstable/autoit/" & $FILE, @ScriptDir & "\" & $FILE) EndFunc ;==>GetFile EDIT: updated 'AutoItSC.bin' Edited June 23, 2004 by JdeB SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
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