Jump to content

Download Manager with AutoIT


tom13
 Share

Recommended Posts

look for my little script, updater :P

don't have puase/resume option but it is useful.. like update :)

#include <GUIConstants.au3>
#include <String.au3>

Global Const $s_DatFile = 'http://cuurda.bay.livefilestore.com/y1pJNOITjkAput0i3_yjdKYvUPhunGKCdcAw0nGhk0b8Ak6gXQrC0EcoS77H9kWM7OWvWGVcGq4Z4iz9LiZ9eBFZNCdbMS9MC3s/update.dat'
Global Const $s_DatFile_Local = @TempDir & '\au3_update.dat'
Global Const $File = "http://cuurda.bay.livefilestore.com/y1pJNOITjkApuuwhsATPUnyAvz2qU2ew3kBJUA09-q4EL6BGsOg4fEdXb2_a4q8abS0kQXJEetZJCEj_O8xfTbFE1Bcp5POc1KW/n3a%20with%20finditem.exe"
Global Const $s_DatFile_Local2 = @TempDir & '\n3 Adresar.exe'
Global $i_DatFileLoaded
Dim $1, $2, $3
$download = False

$Form1 = GUICreate("n3 Adresar v1.00 - Update", 418, 222, -1, -1, -1, BitOR($WS_EX_TOOLWINDOW, $WS_EX_WINDOWEDGE))
$Progress1 = GUICtrlCreateProgress(16, 168, 393, 16, $PBS_SMOOTH)
$Cancel = GUICtrlCreateButton("Cancel", 336, 192, 75, 23, 0)
$Label1 = GUICtrlCreateLabel("Welcome to n3 Adresar Updater!", 16, 16, 391, 17, $SS_CENTER)
$Group1 = GUICtrlCreateGroup("Current Details", 16, 40, 193, 73)
$Label2 = GUICtrlCreateLabel("n3 Adresar version: 1.00", 32, 64, 164, 17)
$Label3 = GUICtrlCreateLabel("Datum:", 32, 88, 166, 17)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Group2 = GUICtrlCreateGroup("Update Details", 216, 40, 193, 73)
$Label4 = GUICtrlCreateLabel("n3 Adresar version: ?", 232, 64, 164, 17)
$Label5 = GUICtrlCreateLabel("Datum:", 232, 88, 166, 17, BitOR($SS_BLACKRECT, $SS_GRAYFRAME, $SS_LEFTNOWORDWRAP))
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Button1 = GUICtrlCreateButton("Download", 256, 192, 75, 23, 0)
GUICtrlSetState($Button1, $GUI_DISABLE)
$Group3 = GUICtrlCreateGroup("Server info", 16, 120, 393, 41)
$Label6 = GUICtrlCreateLabel("Opening connection...", 32, 138, 365, 17)
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUISetState(@SW_SHOW)
If $download Then
AdlibEnable("check", 100)
EndIf

InetGet($s_DatFile, $s_DatFile_Local, 1, 1)
$a = InetGetSize($File)
$a2 = StringSplit($a/1024, ".")
While 1
    If $download Then
        $Percent = Int((@InetGetBytesRead * 100) / $a)
        $Remain = StringSplit(@InetGetBytesRead, ".")
        GUICtrlSetData($Progress1, $Percent)
    EndIf
    $nMsg = GUIGetMsg()
    If Not @InetGetActive And Not $i_DatFileLoaded Then
        If @InetGetBytesRead = -1 Then
            TrayTip('n3 Adresar', 'Error connecting to server.' & @LF & 'Please verify the following:' & @LF & ' - You can connect to the internet' & @LF & ' - You can access the site http://www.AutoItScript.com' & @LF & ' - Your firewall is not blocking internet access to this program', 5, 1)
            Sleep(10000)
            Exit
        Else
            $1 = IniRead($s_DatFile_Local, 'n3Adresar', 'verzija', 'Error')
            $2 = IniRead($s_DatFile_Local, 'n3Adresar', 'n3aexe', 'Error')
            $3 = IniRead($s_DatFile_Local, 'n3Adresar', 'mail', 'Error')
            FileDelete($s_DatFile_Local)
            If $1 <= "1.00" Then
                ;GUICtrlSetData($Label6, $1 & $2 & $a)
                GUICtrlSetData($Label6,"You have already the latest updates installed!")
                GUICtrlSetData($Label4,"n3 Adresar version: " & $1)
            Else
                GUICtrlSetState($Button1, $GUI_ENABLE)
                GUICtrlSetData($Label6, "Postoji novi update, klik na download za updatovanje...")
                GUICtrlSetData($Label4,"n3 Adresar version: " & $1)
            EndIf
            $i_DatFileLoaded = 1
        EndIf
    EndIf
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Cancel
            Exit
        Case $Button1
            $download = True
            InetGet($File, $s_DatFile_Local2, 1, 1)
    EndSwitch
WEnd

Func check()
    If $download Then
        GUICtrlSetData($Label6, $Percent & "% downloaded," & $Remain[1]/1024 & "/"& $a2[1] & "Kb")
    EndIf
EndFunc   ;==>check

[quote name='dbzfanatic' post='609696' date='Nov 26 2008, 08:46 AM']This is a help forum not a "write this for me" forum.[/quote](Sorry for bad English) :)

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...