Download funktioniert nicht richtig.

  • Also, ich habe mir da was zusammengebastelt, teilweise aus Threads hier im Forum.

    [autoit]


    #include <GUIConstantsEx.au3>
    #include "GUICreateTransparent.au3"
    #include <StaticConstants.au3>
    #include <EditConstants.au3>
    #include <ComboConstants.au3>
    #include <GuiConstants.au3>
    #include <WindowsConstants.au3>

    [/autoit][autoit][/autoit][autoit]

    Global Const $SC_DRAGMOVE = 0xF012

    [/autoit][autoit][/autoit][autoit][/autoit][autoit]

    ; Transparentes GUI erzeugen
    $hGUI = _GUICreate_Transparent($sBilddatei)

    [/autoit][autoit][/autoit][autoit]

    ; Child-GUI mit Controls erzeugen
    $hChild = GUICreate("MDIChild", 700, 400, 150, 150, $WS_POPUP, $WS_EX_MDICHILD + $WS_EX_LAYERED, $hGUI)
    GUISetBkColor(0x123456)
    $input1 = GUICtrlCreateInput("", 20, 10, 300, 20)
    $input2 = GUICtrlCreateInput("", 20, 40, 300, 20)
    $input3 = GUICtrlCreateInput("", 20, 70, 300, 20)
    $input4 = GUICtrlCreateInput("", 20, 100, 300, 20)
    $input5 = GUICtrlCreateInput("", 20, 130, 300, 20)
    $button1 = GUICtrlCreateButton("Download beginnen", 20, 170, 300, 25)
    $button2 = GUICtrlCreateButton("Update", 500, 10, 100, 25)
    ; Hintergrundfarbe des Child-GUI transparent setzen
    _WinAPI_SetLayeredWindowAttributes($hChild, 0x123456, 0xff)

    [/autoit][autoit][/autoit][autoit]

    GUISetState(@SW_SHOW, $hGUI)
    GUISetState(@SW_SHOW, $hChild)

    [/autoit][autoit][/autoit][autoit]

    ; Wenn man das GUI bewegen will
    GUIRegisterMsg($WM_LBUTTONDOWN, "_WM_LBUTTONDOWN")
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $button1
    $fn = $input1
    while StringInStr($fn, "/") > 0
    $fn = StringTrimLeft($fn, StringInStr($fn, "/"))
    wend
    $download = InetGetSize ($input1, 1)
    $Form1 = GUICreate("Download", 300, 120)
    $Progress1 = GUICtrlCreateProgress(20, 30, 260, 25)
    $label1 = GUICtrlCreatelabel($fn, 21, 13, 260, 15)
    $label2 = GUICtrlCreatelabel("0 KB von " & int($download/1024) & " KB", 21, 59, 260, 15 )
    GUISetState(@SW_SHOW)
    Opt("GuiOnEventMode", 0)
    if $download > 0 then
    $update = InetGet ($input1, @ScriptDir & "\"&$fn, 1, 1)
    local $sofar, $diff2
    GUICtrlSetData($button1,"Cancel")
    do

    GUICtrlSetData($button1,".")

    $sofar=InetGetInfo($update, 0)
    sleep(50)
    $diff2=InetGetInfo($update, 0)
    GUICtrlSetData($Progress1, int(($sofar/$download)*100))
    GUICtrlSetData($label2, int($sofar/1024) & " KB von " & int($download/1024) & " KB (" & round(($diff2-$sofar)/51.2, 1) & " KB/s)")
    if InetGetInfo($update, 2) then GUICtrlSetData($button1,".")
    until GUICtrlRead ($button1) = "."
    if InetGetInfo($update, 2) and InetGetInfo($update, 3) then
    InetClose($update)
    GUIDelete($form1)
    Else
    GUIDelete($form1)
    InetClose($update)
    if msgbox (21,"Download","Download fehlgeschlagen!") = 4 then $update = 0
    endif
    Else
    GUIDelete($form1)
    if msgbox (21,"Download","Download fehlgeschlagen!") = 2 then $update = -1
    endif
    Opt("GuiOnEventMode", 1)
    EndSwitch
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    Exit

    [/autoit][autoit][/autoit][autoit]

    Func _WM_LBUTTONDOWN($hWnd, $iMsg, $wParam, $lParam)
    _SendMessage($hGUI, $WM_SYSCOMMAND, $SC_DRAGMOVE, 0)
    EndFunc ;==>_WM_LBUTTONDOWN

    [/autoit]

    Aber irgendwie passiert nix, wenn ich auf den Button drücke

  • Ich habe das Include File GUICreateTransparent.au3 nicht. Du solltest diese vielleicht anhängen, dann kann man dir schneller helfen und muss nicht erst nach dem Include suchen ;).
    Edit: Außerdem wird die Variable $sBilddatei verwendet ohne vorher deklariert zu sein. Ein funktionsfähiges Script wäre schon nützlich, und das Script wird es ja wohl geben wenn es bei dir an einem Klick auf einen Button scheitert und nicht am starten des Scripts.

  • [autoit]


    #include <GUIConstantsEx.au3>
    #include "GUICreateTransparent.au3"
    #include <StaticConstants.au3>
    #include <EditConstants.au3>
    #include <ComboConstants.au3>
    #include <GuiConstants.au3>
    #include <WindowsConstants.au3>

    [/autoit][autoit][/autoit][autoit]

    Global Const $SC_DRAGMOVE = 0xF012
    $sBilddatei = "bg.png"

    [/autoit][autoit][/autoit][autoit]

    ; Transparentes GUI erzeugen
    $hGUI = _GUICreate_Transparent($sBilddatei)

    [/autoit][autoit][/autoit][autoit]

    ; Child-GUI mit Controls erzeugen
    $hChild = GUICreate("MDIChild", 700, 400, 150, 150, $WS_POPUP, $WS_EX_MDICHILD + $WS_EX_LAYERED, $hGUI)
    GUISetBkColor(0x123456)
    $input1 = GUICtrlCreateInput("", 20, 10, 300, 20)
    $input2 = GUICtrlCreateInput("", 20, 40, 300, 20)
    $input3 = GUICtrlCreateInput("", 20, 70, 300, 20)
    $input4 = GUICtrlCreateInput("", 20, 100, 300, 20)
    $input5 = GUICtrlCreateInput("", 20, 130, 300, 20)
    $button1 = GUICtrlCreateButton("Download beginnen", 20, 170, 300, 25)
    $button2 = GUICtrlCreateButton("Update", 500, 10, 100, 25)
    ; Hintergrundfarbe des Child-GUI transparent setzen
    _WinAPI_SetLayeredWindowAttributes($hChild, 0x123456, 0xff)

    [/autoit][autoit][/autoit][autoit]

    GUISetState(@SW_SHOW, $hGUI)
    GUISetState(@SW_SHOW, $hChild)

    [/autoit][autoit][/autoit][autoit]

    ; Wenn man das GUI bewegen will
    GUIRegisterMsg($WM_LBUTTONDOWN, "_WM_LBUTTONDOWN")
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $button1
    $fn = $input1
    while StringInStr($fn, "/") > 0
    $fn = StringTrimLeft($fn, StringInStr($fn, "/"))
    wend
    $download = InetGetSize ($input1, 1)
    $Form1 = GUICreate("Download", 300, 120)
    $Progress1 = GUICtrlCreateProgress(20, 30, 260, 25)
    $label1 = GUICtrlCreatelabel($fn, 21, 13, 260, 15)
    $label2 = GUICtrlCreatelabel("0 KB von " & int($download/1024) & " KB", 21, 59, 260, 15 )
    GUISetState(@SW_SHOW)
    Opt("GuiOnEventMode", 0)
    if $download > 0 then
    $update = InetGet ($input1, @ScriptDir & "\"&$fn, 1, 1)
    local $sofar, $diff2
    GUICtrlSetData($button1,"Cancel")
    do

    GUICtrlSetData($button1,".")

    $sofar=InetGetInfo($update, 0)
    sleep(50)
    $diff2=InetGetInfo($update, 0)
    GUICtrlSetData($Progress1, int(($sofar/$download)*100))
    GUICtrlSetData($label2, int($sofar/1024) & " KB von " & int($download/1024) & " KB (" & round(($diff2-$sofar)/51.2, 1) & " KB/s)")
    if InetGetInfo($update, 2) then GUICtrlSetData($button1,".")
    until GUICtrlRead ($button1) = "."
    if InetGetInfo($update, 2) and InetGetInfo($update, 3) then
    InetClose($update)
    GUIDelete($form1)
    Else
    GUIDelete($form1)
    InetClose($update)
    if msgbox (21,"Download","Download fehlgeschlagen!") = 4 then $update = 0
    endif
    Else
    GUIDelete($form1)
    if msgbox (21,"Download","Download fehlgeschlagen!") = 2 then $update = -1
    endif
    Opt("GuiOnEventMode", 1)
    EndSwitch
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    Exit

    [/autoit][autoit][/autoit][autoit]

    Func _WM_LBUTTONDOWN($hWnd, $iMsg, $wParam, $lParam)
    _SendMessage($hGUI, $WM_SYSCOMMAND, $SC_DRAGMOVE, 0)
    EndFunc ;==>_WM_LBUTTONDOWN

    [/autoit][autoit][/autoit][autoit][/autoit]