botanic Posted January 12, 2007 Posted January 12, 2007 It wont show the progress during the update... CODEglobal $difernce, $update, $somx, $i, $filelist, $filesize, $Progress1, $SS_CENTER1, $GUI_BKCOLOR_TRANSPARENT, $updt, $form1 Dim $Udif, $QT_web = "www.ProjectGremBot.somee.com" Func CreateProgress($x, $y, $w, $h, $Label="") Dim $Progress[2] $Progress[0] = GuiCtrlCreateProgress($x, $y, $w, $h) $Progress[1] = GuiCtrlCreateLabel($Label, $x, $y+3, $w, $h, $SS_CENTER ) GUICtrlSetBkColor($Progress[1], $GUI_BKCOLOR_TRANSPARENT) Return $Progress EndFunc Func UpdateProgress($ProgressID, $Percent, $Label="") GUICtrlSetData($ProgressID[0], $Percent) GUICtrlSetData($ProgressID[1], $Label & $Percent & "%") EndFunc ;test FileDelete("updatenew.txt") InetGet("http://www.projectgrembot.somee.com/updatenew.txt", "updatenew.txt", 1, 0) if FileExists("update.exe") = 0 Then IniWrite("update.exe", "update", "ProjectGremBot.txt", "v1") EndIf if IniRead("updatenew.txt", "update", "ProjectGremBot.exe", "") <> IniRead("update.txt", "update", "ProjectGremBot.exe", "") Then $updt = MsgBox( 3, "Update?", "ProjectGremBot has been updated do you want to download this update?") if $updt = 6 then $somx = IniRead("updatenew.txt", "update", "ProjectGremBot.exe", "") InetGet("http://www.projectgrembot.somee.com/ProjectGremBot" & $somx & ".exe", "ProjectGremBot" & $somx & ".exe", 1, 1) $filesize = InetGetSize("http://www.projectgrembot.somee.com/ProjectGremBot.exe") $Form1 = GUICreate("AForm1", 392, 71, 193, 115) $Progress1 = CreateProgress(16, 16, 353, 25) GUICtrlSetData(-1, 25) GUISetState(@SW_SHOW) for $i = 1 to $filesize UpdateProgress($Progress1, $i / @InetGetBytesRead * 100) sleep(500) Next IniWrite("update.txt", "update", "ProjectGremBot.exe", $somx) IniWrite("updatenew.txt", "update", "ProjectGremBot.exe", $somx) MsgBox( 1, "New Ver!!!", "Please use the new version of ProjectGremBot") Run("ProjectGremBot" & $somx & ".exe") _Exit() if $updt = 2 then exit EndIf EndIf
MrSpacely Posted January 13, 2007 Posted January 13, 2007 (edited) Hmm I havent tested anything but I saw something weird. you declared $SS_CENTER1, $GUI_BKCOLOR_TRANSPARENT But they donot get a value. And they are used to set certain things in the gui objects. Too make shure that those parameters actually work use #include <GUIConstants.au3> to load the correct variables otherwise it won't change any parameters because they are empty. Next thing. for $i = 1 to $filesize UpdateProgress($Progress1, $i / @InetGetBytesRead * 100) sleep(500) Next This would count to filesize (wich can take really long in this way) if the program is 300kb it wil take at least 150 000 seconds before the program continues. Better try to use a loop wich checks every half a second if the downloading is finished using @InetGetActive if its not finished then set the progressbar to the correct percentage. And its not working because it starts ($i) at 1 then counts up really slowly to 2 etc etc the download goes much faster after 1 second you might have 5000bytes (at modem speed) wich means 1 / 5000 *100 = 0,02 and that will be 0 percent. thats why you cannot see any change. I even think the program doesn't stop after the download is ready (but about 70 hours if the file is 500kb) The rest of the code is allright except the weird for loop with incorrect variables used. And the use of empty parameter variables. I hope you can make it work now otherwise just send a message (because I sometimes write really illogicaly) It wont show the progress during the update... CODEglobal $difernce, $update, $somx, $i, $filelist, $filesize, $Progress1, $SS_CENTER1, $GUI_BKCOLOR_TRANSPARENT, $updt, $form1 Dim $Udif, $QT_web = "www.ProjectGremBot.somee.com" Func CreateProgress($x, $y, $w, $h, $Label="") Dim $Progress[2] $Progress[0] = GuiCtrlCreateProgress($x, $y, $w, $h) $Progress[1] = GuiCtrlCreateLabel($Label, $x, $y+3, $w, $h, $SS_CENTER ) GUICtrlSetBkColor($Progress[1], $GUI_BKCOLOR_TRANSPARENT) Return $Progress EndFunc Func UpdateProgress($ProgressID, $Percent, $Label="") GUICtrlSetData($ProgressID[0], $Percent) GUICtrlSetData($ProgressID[1], $Label & $Percent & "%") EndFunc ;test FileDelete("updatenew.txt") InetGet("http://www.projectgrembot.somee.com/updatenew.txt", "updatenew.txt", 1, 0) if FileExists("update.exe") = 0 Then IniWrite("update.exe", "update", "ProjectGremBot.txt", "v1") EndIf if IniRead("updatenew.txt", "update", "ProjectGremBot.exe", "") <> IniRead("update.txt", "update", "ProjectGremBot.exe", "") Then $updt = MsgBox( 3, "Update?", "ProjectGremBot has been updated do you want to download this update?") if $updt = 6 then $somx = IniRead("updatenew.txt", "update", "ProjectGremBot.exe", "") InetGet("http://www.projectgrembot.somee.com/ProjectGremBot" & $somx & ".exe", "ProjectGremBot" & $somx & ".exe", 1, 1) $filesize = InetGetSize("http://www.projectgrembot.somee.com/ProjectGremBot.exe") $Form1 = GUICreate("AForm1", 392, 71, 193, 115) $Progress1 = CreateProgress(16, 16, 353, 25) GUICtrlSetData(-1, 25) GUISetState(@SW_SHOW) for $i = 1 to $filesize UpdateProgress($Progress1, $i / @InetGetBytesRead * 100) sleep(500) Next IniWrite("update.txt", "update", "ProjectGremBot.exe", $somx) IniWrite("updatenew.txt", "update", "ProjectGremBot.exe", $somx) MsgBox( 1, "New Ver!!!", "Please use the new version of ProjectGremBot") Run("ProjectGremBot" & $somx & ".exe") _Exit() if $updt = 2 then exit EndIf EndIf Edited January 13, 2007 by MrSpacely
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