zone97 Posted April 16, 2008 Share Posted April 16, 2008 Here is the auto updater I created. This program reads a version.ini file and compares it to a current.ini file and if the new version# is greater, it downloads the update and closes the existing program and launches the new version. This works good for a few minutes then stops doing what it is designed to? It is not crashing, just not checking for the version.ini any longer. The webserver does not register any hits after a certain amount of time. It has no gui, just a tray icon, clicking the icon closes the app, you can also do a CTRL-ALT-X. Could someone please look this over and point out anything that could be done better, or why it may be stop responding? Thanks. ** the web server has been changed to protect the innocent. ** expandcollapse popup#NoTrayIcon #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_icon=promon_u.ico #AutoIt3Wrapper_UseAnsi=y #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** ;############################################################################## ;# Options HotKeySet("^!x","quit") #include <GuiConstants.au3> #include <Constants.au3> #include <inet.au3> Opt("TrayOnEventMode", 1) Opt("TrayMenuMode", 1) Opt("WinWaitDelay", 750) TraySetIcon("promon_u.ico") TraySetOnEvent($TRAY_EVENT_PRIMARYUP, "SpecialEvent") ;############################################################################## ;# GUI Form Information GUISetState() ;@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ ;@ Program Start While 1 checkver() WEnd ;############################################################################## ;# Functions ; FUNC: Minimize to tray. Func SpecialEvent() Exit EndFunc ; FUNC: Check version Func checkver() FileDelete("version.ini") Sleep(250) InetGet("http://mywebserver.com/version.ini", @ScriptDir & "\version.ini", 1, 0) Sleep(1000) $version1 = IniRead("current.ini", "version", "version", "") $version2 = IniRead("version.ini", "version", "version", "") if $version1 < $version2 Then update() Sleep(1000) EndFunc ; FUNC: Update the software Func update() $FileURL = "http://mywebserver.com/promon.exe" $FileName = "promon_new.exe" $FileSize = InetGetSize($FileURL) InetGet($FileURL,$FileName,0,1) ProgressOn("Progress Meter", "Increments every second", "0 percent") While @InetGetActive $Percentage = @InetGetBytesRead * 100 / $FileSize ProgressSet($Percentage,"Downloaded " & @InetGetBytesRead & " of " & $FileSize & " bytes","Downloading " & $FileName) Sleep(250) Wend ProgressOff() WinClose("Process Monitor","") Sleep(2000) FileCopy("version.ini","current.ini",1) FileCopy(@ScriptDir & "\promon_new.exe",@ScriptDir & "\promon.exe",1) FileDelete(@ScriptDir & "\promon_new.exe") Run(@ScriptDir & "\promon.exe") Sleep(2000) ControlClick("Process Monitor","","Button1","Left",1) EndFunc Func quit() Exit EndFunc Spoiler WinSizer 2.1 (01/04/2017) - Download - [ Windows Layout Manager ]Folder+Program (12/23/2016) - Download - [ USB Shortcut Creator ] Link to comment Share on other sites More sharing options...
Swift Posted April 16, 2008 Share Posted April 16, 2008 1) It Burns CPU 2) Don't Use The InetGet() Use a _IE* function to read the page.. (much faster), 3)_VersionCompare() To compare the files... 4) If using version compare...dont use a .ini..use a fileread...and etc... Just some things I saw.. Link to comment Share on other sites More sharing options...
zone97 Posted April 17, 2008 Author Share Posted April 17, 2008 1) It Burns CPU2) Don't Use The InetGet() Use a _IE* function to read the page.. (much faster),3)_VersionCompare() To compare the files...4) If using version compare...dont use a .ini..use a fileread...and etc...Just some things I saw..When you say burn CPU do you mean cause its working all the time? Im not objectionable to a timer, however I do not really like the sleep function because it prevents the application from responding to a close request.i'm new to autoit, could you show me how those items you suggested work?Thanks. Spoiler WinSizer 2.1 (01/04/2017) - Download - [ Windows Layout Manager ]Folder+Program (12/23/2016) - Download - [ USB Shortcut Creator ] Link to comment Share on other sites More sharing options...
Swift Posted April 17, 2008 Share Posted April 17, 2008 Put a Sleep(50) in there, it will not seem to slow it down, but it stops the burn of CPU. _VersionCompare() It's in the Misc.au3 file. _InetGetSource() might be what you need or use a _IE* function to read the txt without downloading it. And use FileWrite, FileRead, FileReadLine() Etc. to see the actual version without using a .ini Link to comment Share on other sites More sharing options...
zone97 Posted April 17, 2008 Author Share Posted April 17, 2008 (edited) Put a Sleep(50) in there, it will not seem to slow it down, but it stops the burn of CPU. _VersionCompare() It's in the Misc.au3 file. _InetGetSource() might be what you need or use a _IE* function to read the txt without downloading it. And use FileWrite, FileRead, FileReadLine() Etc. to see the actual version without using a .ini There is 2.25 seconds of sleep time durring the main function of looking at the version info? Does it need more? could you do something like.. for x$ 1 to 120 sleep(1000) ** do soemthing here to still listen for keyboard commands. next that way you sleep for 1 second at a time for 120 seconds while still responding to mouse clicks and such? also checked the logs, it seems to work for around 30 - 35 minutes before stopping? any clue? Edited April 17, 2008 by zone97 Spoiler WinSizer 2.1 (01/04/2017) - Download - [ Windows Layout Manager ]Folder+Program (12/23/2016) - Download - [ USB Shortcut Creator ] 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