Jump to content

Update Program


Recommended Posts

I've been trying to make an updater/launcher type thing to upgrade my current one that goes with my program I have. But I can't seem to make it download more then one file.

This is my code

#include <E:\Program Files\AutoIt3\Include\ButtonConstants.au3>
#include <E:\Program Files\AutoIt3\Include\EditConstants.au3>
#include <E:\Program Files\AutoIt3\Include\GUIConstantsEx.au3>
#include <E:\Program Files\AutoIt3\Include\WindowsConstants.au3>
#include <E:\Program Files\AutoIt3\Include\StaticConstants.au3>
#NoTrayIcon
#AutoIt3Wrapper_Icon=TwelveSky.ico
AutoItSetOption("GUIOnEventMode", 1)

$GUITitle = "K1ll 0n S1ght Launcher"
$GUIWidth = 400
$GUIHeight = 400
Dim $iDloadFinalSize = ""
Dim $iDloadCurrentSize = ""

$GUI = GUICreate($GUITitle, $GUIWidth, $GUIHeight, (@DesktopWidth - $GUIWidth) / 2, (@DesktopHeight - $GUIHeight) / 2)
$Pic1 = GUICtrlCreatePic("E:\Documents and Settings\Jared\Desktop\AutoIt3 Scripts\800x600.jpg", 0, 0, 400, 345, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS))
$buttonDownload = GUICtrlCreateButton("Update", 155, 350, 100, 20)
$buttonstart = GUICtrlCreateButton("Start", 50, 350, 100, 20)
$progressDownloadStatus = GUICtrlCreateProgress(5, 380, $GUIWidth - 10, 10)
GUISetState()

#Region Events list
GUISetOnEvent($GUI_EVENT_CLOSE, "_ExitIt")
GUICtrlSetOnEvent($buttonDownload,"_DownloadFF")
#EndRegion Events list

While 1
    Sleep(10)
    If $iDloadFinalSize <> "" Then _CheckActiveDownload()
WEnd

Func _ExitIt()
    Exit
EndFunc

Func _CheckActiveDownload()
    If @InetGetBytesRead <> "-1" Then
        $iDloadCurrentSize = @InetGetBytesRead
        $iPercentage = Int(($iDloadCurrentSize/$iDloadFinalSize)*100)
        GUICtrlSetData($progressDownloadStatus,$iPercentage)
    Else
        $iDloadFinalSize = ""
        GUICtrlSetData($progressDownloadStatus,"0")
        MsgBox(16,"Error","The download was cancelled, or did not complete successfully.")
    EndIf
        GUICtrlCreateLabel("Progress:", 300, 354, 100, 20)
        GUICtrlCreateLabel($iPercentage, 350, 354, 100, 20)
    If $iDloadCurrentSize = $iDloadFinalSize Then
        $iDloadFinalSize = ""
        Sleep(2000)
    EndIf
EndFunc

Func _DownloadFF()
    If @InetGetActive Then
        Sleep(1000)
    Else
        GUICtrlSetData($progressDownloadStatus,"0")
        $iDloadCurrentSize = "0"
        $sFileURL = "http://jared.brycestateofmind.com/Release/1.3.0/TwelveSky2.exe"
        $sFileDest = @WorkingDir & "\TwelveSky2 Bot v1.3.1.exe"
        $iDloadFinalSize = InetGetSize($sFileURL)
        InetGet($sFileURL, $sFileDest, 1, 1)
        $iDloadCurrentSize = "0"
        DownloadFF2()
    EndIf
EndFunc

Func DownloadFF2()
    If @InetGetActive Then
        Sleep(1000)
    Else
        GUICtrlSetData($progressDownloadStatus,"0")
        $iDloadCurrentSize = "0"
        $sFileURL = "http://jared.brycestateofmind.com/Release/1.3.0/ext/Update.exe"
        $sFileDest = @WorkingDir & "ext\Update.exe"
        $iDloadFinalSize = InetGetSize($sFileURL)
        InetGet($sFileURL, $sFileDest, 1, 1)
        $iDloadCurrentSize = "0"
        DownloadFF3()
    EndIf
EndFunc

Func DownloadFF3()
    If @InetGetActive Then
        Sleep(1000)
    Else
        GUICtrlSetData($progressDownloadStatus,"0")
        $iDloadCurrentSize = "0"
        $sFileURL = "http://jared.brycestateofmind.com/Release/1.3.0/ext/Spirit.exe"
        $sFileDest = @WorkingDir & "ext\Spirit.exe"
        $iDloadFinalSize = InetGetSize($sFileURL)
        InetGet($sFileURL, $sFileDest, 1, 1)
        $iDloadCurrentSize = "0"
        DownloadFF4()
    EndIf
EndFunc

Func DownloadFF4()
    If @InetGetActive Then
        Sleep(1000)
    Else
        GUICtrlSetData($progressDownloadStatus,"0")
        $iDloadCurrentSize = "0"
        $sFileURL = "http://jared.brycestateofmind.com/Release/1.3.0/ext/Loot.exe"
        $sFileDest = @WorkingDir & "ext\Loot.exe"
        $iDloadFinalSize = InetGetSize($sFileURL)
        InetGet($sFileURL, $sFileDest, 1, 1)
        $iDloadCurrentSize = "0"
        DownloadFF5()
    EndIf
EndFunc

Func DownloadFF5()
    If @InetGetActive Then
        Sleep(1000)
    Else
        GUICtrlSetData($progressDownloadStatus,"0")
        $iDloadCurrentSize = "0"
        $sFileURL = "http://jared.brycestateofmind.com/Release/1.3.0/ext/Login.exe"
        $sFileDest = @WorkingDir & "ext\Login.exe"
        $iDloadFinalSize = InetGetSize($sFileURL)
        InetGet($sFileURL, $sFileDest, 1, 1)
        $iDloadCurrentSize = "0"
        DownloadFF6()
    EndIf
EndFunc

Func DownloadFF6()
    If @InetGetActive Then
        Sleep(1000)
    Else
        GUICtrlSetData($progressDownloadStatus,"0")
        $iDloadCurrentSize = "0"
        $sFileURL = "http://jared.brycestateofmind.com/Release/1.3.0/ext/Health.exe"
        $sFileDest = @WorkingDir & "ext\Health.exe"
        $iDloadFinalSize = InetGetSize($sFileURL)
        InetGet($sFileURL, $sFileDest, 1, 1)
        $iDloadCurrentSize = "0"
        DownloadFF7()
    EndIf
EndFunc

Func DownloadFF7()
    If @InetGetActive Then
        Sleep(1000)
    Else
        GUICtrlSetData($progressDownloadStatus,"0")
        $iDloadCurrentSize = "0"
        $sFileURL = "http://jared.brycestateofmind.com/Release/1.3.0/ext/Buff.exe"
        $sFileDest = @WorkingDir & "ext\Buff.exe"
        $iDloadFinalSize = InetGetSize($sFileURL)
        InetGet($sFileURL, $sFileDest, 1, 1)
        $iDloadCurrentSize = "0"
    EndIf
EndFunc
Link to comment
Share on other sites

It looks to me like you're not properly resetting $iDloadFinalSize to "" when you complete a download. That makes you hange in the while loop, and you don't move on to the second one.

I'd suggest running a watch on $iDloadCurrentSize and $iDloadFinalSize to make sure that they're exactly equal when a download finishes.

Edited by orange
Link to comment
Share on other sites

Would this be correct? Sorry if I'm wrong, the INetGet calls aren't really my strong suit.

Func _DownloadFF()
    If @InetGetActive Then
        Sleep(1000)
    Else
        GUICtrlSetData($progressDownloadStatus,"0")
        $iDloadCurrentSize = ""
        $sFileURL = "http://jared.brycestateofmind.com/Release/1.3.0/TwelveSky2.exe"
        $sFileDest = @WorkingDir & "\TwelveSky2 Bot v1.3.1.exe"
        $iDloadFinalSize = InetGetSize($sFileURL)
        InetGet($sFileURL, $sFileDest, 1, 1)
        DownloadFF2()
    EndIf
EndFunc

Func DownloadFF2()
    If @InetGetActive Then
        Sleep(1000)
    Else
        GUICtrlSetData($progressDownloadStatus,"0")
        $iDloadCurrentSize = ""
    $iDloadFinalSize = ""
        $sFileURL = "http://jared.brycestateofmind.com/Release/1.3.0/ext/Update.exe"
        $sFileDest = @WorkingDir & "ext\Update.exe"
        $iDloadFinalSize = InetGetSize($sFileURL)
        InetGet($sFileURL, $sFileDest, 1, 1)
        DownloadFF3()
    EndIf
EndFunc
Edited by JaredT
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...