IniRead数组并通过进度条传递给下载功能

时间:2014-11-25 01:25:16

标签: autoit

所以我正在尝试找出如何在我正在使用的工具中使用下载器功能,基本上是一个带有3个下载按钮的选项卡,基于在标签中单击的按钮我喜欢它传递给一个函数,下载器将从ini文件中读取链接,在选项卡中有一个进度条我会发布下面的代码,这样你就可以理解了

所以它会下载文件绝对正常唯一的问题是,当我启动应用程序时,即使我没有单击选项卡中的标签,也不会自动启动数组中第一个文件的下载,其余的GUI功能,我无法切换标签,因为它只是“冻结”然后下载重新开始,如果我评论出$ modlabel1的情况dwitch像这样“; Case $ modlabel1”它允许我切换标签等就好了我可以切换选项卡并单击其他2个按钮,他们将按预期下载,但GUI保留在mod选项卡上直到完成,我有另一个小问题是我需要下载文件与源文件名相同,那可能与InetGet有关吗?

下载标签

Func _mods_gui()
    $modsgui = GUICreate("Mods", 1270, 610, 5, 105, BitOR($ws_popup, $ws_border), $ws_ex_mdichild, $maingui)
    GUISetBkColor(3487029)
    DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $setgui, "int", 250, "long", 524288)
    $progressbar1 = GUICtrlCreateProgress(10, 200, 1250, 50, $PBS_MARQUEE)
    $modlabel1 = GUICtrlCreateLabel("Download" & @CRLF & "DayZ Epoch 1.0.5.1", 50, 50, 350, 100, $ss_center)
    GUICtrlSetFont(-1, 30, 700, 0, "Segeo UI", 4)
    GUICtrlSetBkColor(-1, 3825)
    GUICtrlSetColor(-1, 16777215)
    _guictrl_setonhover(-1, "_Hover", "_Hover_Leave")
    $modlabel2 = GUICtrlCreateLabel("Download" & @CRLF & "DayZ Overwatch 0.2.5", 450, 50, 350, 100, $ss_center)
    GUICtrlSetFont(-1, 30, 700, 0, "Segeo UI", 4)
    GUICtrlSetBkColor(-1, 3825)
    GUICtrlSetColor(-1, 16777215)
    _guictrl_setonhover(-1, "_Hover", "_Hover_Leave")
    $modlabel3 = GUICtrlCreateLabel("Download" & @CRLF & "Namalsk 0.75", 850, 50, 350, 100, $ss_center)
    GUICtrlSetFont(-1, 30, 700, 0, "Segeo UI", 4)
    GUICtrlSetBkColor(-1, 3825)
    GUICtrlSetColor(-1, 16777215)
    _guictrl_setonhover(-1, "_Hover", "_Hover_Leave")
    $modsgr2 = GUICtrlCreateGraphic(0, 25, 1270, 250)
    GUICtrlSetState(-1, $gui_disable)
    GUICtrlSetGraphic(-1, $gui_gr_color, 0, 2368548)
    GUICtrlSetGraphic(-1, $gui_gr_rect, 0, 0, 1270, 250)
    GUISetState(@SW_SHOW, $modsgui)
EndFunc

切换案例

Case $modsgui
    Switch $nmsg[0]
        Case $modlabel1
            _downloadmod(0)
        Case $modlabel2
            _downloadmod(1)
        Case $modlabel3
            _downloadmod(2)
    EndSwitch

下载数组

Func _downloadmod($mod)
    $modarrayread[3] = [IniRead(@ScriptDir & "\LauncherFiles\data\XGLConfig.cfg", "mod_links", "mod_epoch", Default), IniRead(@ScriptDir & "\LauncherFiles\data\XGLConfig.cfg", "mod_links", "mod_overwatch", Default), IniRead(@ScriptDir & "\LauncherFiles\data\XGLConfig.cfg", "mod_links", "mod_namalsk", Default)]
    $dwnmod = InetGet($modarrayread[$mod], @ScriptDir & "\Mods\$name.zip", 1, 1)
    Do
        Sleep(50)
        $prc = Round(InetGetInfo($dwnmod, 0) / (InetGetInfo($dwnmod, 1)) * 100)
        GUICtrlSetData($progressbar1, $prc)
    Until InetGetInfo($dwnmod, $INET_DOWNLOADCOMPLETE)
EndFunc

INI

[mod_links]
mod_epoch=http://files.xexgaming.com/mods/@DayZ_Epoch1051.zip
mod_overwatch=http://files.xexgaming.com/mods/@DayZOverwatch.zip
mod_namalsk=http://files.xexgaming.com/mods/@Namalsk.zip

对特洛伊木马有关数组帮助的信用,计算出如何使用他的示例获取参数

1 个答案:

答案 0 :(得分:0)

我使用GUICtrlCreateProgress帮助中的示例脚本作为基础并编写了一个脚本,希望能够完成您希望它做的事情。 如果您有任何问题,请随时询问:)

#include <GUIConstantsEx.au3>
#include <ProgressConstants.au3>
#include <MsgBoxConstants.au3>
#include <InetConstants.au3>

Example()

Func Example()
    Local $progressbar1, $button1, $button2, $button3
    Local $downarrayread[3] = [IniRead(@ScriptDir & "\Files\data\Config.cfg", "links", "link_1", Default), IniRead(@ScriptDir & "\Files\data\Config.cfg", "links", "link_2", Default), IniRead(@ScriptDir & "\Files\data\Config.cfg", "links", "link_3", Default)]
    GUICreate("Downloads", 220, 100, 100, 200)
    $progressbar1 = GUICtrlCreateProgress(10, 40, 200, 20, $PBS_SMOOTH)
    $button1 = GUICtrlCreateButton("Start 1", 5, 70, 70, 20)
    $button2 = GUICtrlCreateButton("Start 2", 75, 70, 70, 20)
    $button3 = GUICtrlCreateButton("Start 3", 145, 70, 70, 20)
    GUISetState(@SW_SHOW)



    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop
            Case $button1
                $hDownload = InetGet($downarrayread[1], @ScriptDir & "/Downloads/File1", $INET_FORCERELOAD, $INET_DOWNLOADBACKGROUND)
                Do
                    Sleep(250)
                    GUICtrlSetData($progressbar1,((InetGetInfo($hDownload,$INET_DOWNLOADSIZE )/InetGetInfo($hDownload, $INET_DOWNLOADREAD))*100)/3)
                Until InetGetInfo($hDownload, $INET_DOWNLOADCOMPLETE)
            Case $button2
                $hDownload = InetGet($downarrayread[2], @ScriptDir & "/Downloads/File2", $INET_FORCERELOAD, $INET_DOWNLOADBACKGROUND)
                Do
                    Sleep(250)
                    GUICtrlSetData($progressbar1,((InetGetInfo($hDownload,$INET_DOWNLOADSIZE )/InetGetInfo($hDownload, $INET_DOWNLOADREAD))*100)/3+33.33)
                Until InetGetInfo($hDownload, $INET_DOWNLOADCOMPLETE)
            Case $button3
                $hDownload = InetGet($downarrayread[3], @ScriptDir & "/Downloads/File3", $INET_FORCERELOAD, $INET_DOWNLOADBACKGROUND)
                Do
                    Sleep(250)
                    GUICtrlSetData($progressbar1,((InetGetInfo($hDownload,$INET_DOWNLOADSIZE )/InetGetInfo($hDownload, $INET_DOWNLOADREAD))*100)/3+66.66)
                Until InetGetInfo($hDownload, $INET_DOWNLOADCOMPLETE)
        EndSwitch
    WEnd

EndFunc   ;==>Example