Jump to content

Close a window during download


Recommended Posts

How to close a window chen a download is in progress ?

And I can also click on any button. Button has'nt effect...

I tested with exit, winkill, inetclose and guidelete, but nothing :(

Qui ose gagneWho Dares Win[left]CyberExploit[/left]

Link to comment
Share on other sites

#include <GUIConstantsEx.au3>
#include <ProgressConstants.au3>
GUICreate("Barre de progression", 220, 100, 100, 200)
$Barre_de_progression = GUICtrlCreateProgress(10, 10, 200, 20)
$Bouton = GUICtrlCreateButton("Démarrer", 75, 70, 70, 20)
$Avancement = GUICtrlCreateLabel("Ouvrir le dossier", 10, 40)
GUISetState()
Do
$msg = GUIGetMsg()
If $msg = $Bouton Then
  $Taille_fichier = InetGetSize("http://download.mythicsoft.com/agentran.exe")
  $Download = InetGet("http://download.mythicsoft.com/agentran.exe", @DesktopDir & "\Test\Ransack.exe", 3, 1)
  Do
   Sleep(200)
   $Taille_intermediaire = InetGetInfo($Download, 0)
   $Pourcentage = 100 * $Taille_intermediaire / $Taille_fichier
   GUICtrlSetData($Barre_de_progression, $Pourcentage)
   GUICtrlSetData($Avancement, "Avancement : " & Round($Pourcentage, 0) & " %")
  Until InetGetInfo($Download, 2)
EndIf
Until $msg = $GUI_EVENT_CLOSE

I tested Opt("GUIOnEventMode", 1) but, I don't understand why buttons doesn't work !!! :)

Qui ose gagneWho Dares Win[left]CyberExploit[/left]

Link to comment
Share on other sites

Lorsque tu démarres le téléchargement, ton script passe dans un sous looping tant que le téléchargement n'est pas terminé; du coup le looping principal qui écoute les événements GUI n'est plus actif et ne peux pas répondre aux différents cliques.

When you start the download, your script goes in a sub loop while the download is not complete; therefore the main loop which listens to the GUI messages is not active and can't answer to various clicks.

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

GUICreate("Barre de progression", 220, 100, 100, 200)
$Barre_de_progression = GUICtrlCreateProgress(10, 10, 200, 20)
$Bouton = GUICtrlCreateButton("Démarrer", 75, 70, 70, 20)
$Avancement = GUICtrlCreateLabel("Ouvrir le dossier", 10, 40)
GUISetState()

Local $Download = 0

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            ExitLoop
        Case $Bouton
            $Taille_fichier = InetGetSize("http://download.mythicsoft.com/agentran.exe")
            $Download = InetGet("http://download.mythicsoft.com/agentran.exe", @DesktopDir & "\Test\Ransack.exe", 3, 1)
    EndSwitch

    If $Download > 0 Then
        $Taille_intermediaire = InetGetInfo($Download, 0)
        $Pourcentage = 100 * $Taille_intermediaire / $Taille_fichier
        GUICtrlSetData($Barre_de_progression, $Pourcentage)
        GUICtrlSetData($Avancement, "Avancement : " & Round($Pourcentage, 0) & " %")

        If InetGetInfo($Download, 2) Then $Download = 0
    EndIf
WEnd

Br, FireFox.

Link to comment
Share on other sites

Whenever you want to manage multiple things, the array is always the best solution.

Like this :

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

Local $iMaxDownload = 5 ;let's say 5 simultaneous max downloads

Local $ahDownload[$iMaxDownload], $aiDlSize[$iMaxDownload]
Local $aiPbProgress[$iMaxDownload], $aiBtnStart[$iMaxDownload], $aiLabelStatus[$iMaxDownload]

#region GUI
Local $hGUI = GUICreate("MyGUI")

For $i = 0 To $iMaxDownload -1
    $aiPbProgress[$i] = GUICtrlCreateProgress(10, 10 + $i * 55, 200, 20)
    $aiBtnStart[$i] = GUICtrlCreateButton("Démarrer", 9, 35 + $i * 55, 70, 20)
    $aiLabelStatus[$i] = GUICtrlCreateLabel("Na", 85, 40 + $i * 55, 200)
Next

GUISetState(@SW_SHOW, $hGUI)
#endregion

Local $iMsg = 0, $iCurrSize = 0, $iPercent = 0

While 1
    $iMsg = GUIGetMsg()
    Switch $iMsg
        Case $GUI_EVENT_CLOSE
            ExitLoop
        Case Else
            For $i = 0 To $iMaxDownload -1
                If $iMsg <> $aiBtnStart[$i] Then ContinueLoop

                $aiDlSize[$i] = InetGetSize("http://download.mythicsoft.com/agentran.exe")
                $ahDownload[$i] = InetGet("http://download.mythicsoft.com/agentran.exe", @DesktopDir  & "\Test\Ransack" & $i & ".exe", 3, 1)
            Next
    EndSwitch

    For $i = 0 To $iMaxDownload -1
        If $ahDownload[$i] = 0 Then ContinueLoop

        $iCurrSize = InetGetInfo($ahDownload[$i], 0)

        $iPercent = 100 * $iCurrSize / $aiDlSize[$i]

        GUICtrlSetData($aiPbProgress[$i], $iPercent)
        GUICtrlSetData($aiLabelStatus[$i], "Avancement : " & Round($iPercent) & " %")

        If InetGetInfo($ahDownload[$i], 2) Then $ahDownload[$i] = 0
    Next
WEnd

Br, FireFox.

Edited by FireFox
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...