Code : Tout sélectionner
#include <GUIConstantsEx.au3>
#include <GuiButton.au3>
#include <WindowsConstants.au3>
#include <StaticConstants.au3>
$GUI = GUICreate("Firefox Download Automatization", 300, 200, -1, -1)
$picb = GUICtrlCreatePic("C:\firefox.jpg",0,0,300,200,BitOR($WS_GROUP,$WS_CLIPSIBLINGS))
$txt1 = GUICtrlCreateLabel("This Program will help you to download automatically the", 10, 30)
$txt2 = GUICtrlCreateLabel("last version of Firefox!",95 , 50)
GUICtrlSetBkColor ( $txt1 , $GUI_BKCOLOR_TRANSPARENT )
GUICtrlSetBkColor ( $txt2 , $GUI_BKCOLOR_TRANSPARENT )
[b]$Telecharger = GUICtrlCreateButton("Download" , 161, 125, 80 , 35)[/b] ; bouton
$ButtonStop = GUICtrlCreateButton("Stop", 250, 125, 30, 35)
$ButtonQuit = GUICtrlCreateButton("Quit", 250, 125, 30, 35)
$grouppercent = GUICtrlCreateGroup("", 10,120, 60,40)
$grouppercent = GUICtrlCreateGroup("", 99, 99, 1 ,1)
$progressbar1 = GUICtrlCreateProgress (10 , 170 , 280 , 20) ; processbar
If (FileExists(@DesktopDir&"/Install-FireFox.exe") = 1) Then
$FileSizeIn = FileGetSize (@DesktopDir&"/Install-FireFox.exe")
EndIf
;If ($FileSize = $FileSizeIn) Then
;GUICtrlSetData($Telecharger , "Install")
;EndIf
$percentage = 0
$temp = GUICtrlRead($Telecharger)
GUICtrlSetColor (- 1 , 32250) ;thème Windows
GUISetState(@SW_SHOW)
GUICtrlSetState($Telecharger, $GUI_FOCUS)
GUICtrlSetState($ButtonQuit, $GUI_HIDE)
GUICtrlSetState($ButtonStop, $GUI_HIDE)
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $Telecharger
If ($temp <> "Install") Then
GUICtrlSetData ( $progressbar1 , 0 )
GUICtrlSetState($ButtonQuit, $GUI_HIDE)
GUICtrlSetState($Telecharger, $GUI_DISABLE)
GUICtrlSetState($ButtonStop, $GUI_SHOW)
GUICtrlSetState($ButtonStop, $GUI_FOCUS)
Global $Url = "http://download.mozilla.org/?product=firefox-3.0rc2&os=win&lang=fr"
$FileSize = InetGetSize ( $Url ) ; ceci calcul la taille de ton fichier qui se trouve sur internet
InetGet( $Url , @DesktopDir&"/Install-FireFox.exe", 1, 1);il sera dl sur le bureau
$txt3 = GUICtrlCreateLabel($percentage & "%", 15, 135)
GUICtrlSetBkColor ( $txt3 , $GUI_BKCOLOR_TRANSPARENT )
While @InetGetActive
;$i = TrayTip("Download...", Int ( ( @InetGetBytesRead * 100 ) / $FileSize )&" %", 10, 16)
GUICtrlSetData ( $progressbar1 , Int ( ( @InetGetBytesRead * 100 ) / $FileSize ) )
;$percentage= (Int(( @InetGetBytesRead * 100 )*100 / $FileSize)/10)
;GUICtrlCreateLabel(Int(( @InetGetBytesRead * 100 )*10 / $FileSize)/10, 60, 90)
If ($percentage <> (Int(( @InetGetBytesRead * 100 ) / $FileSize))) Then
$percentage= (Int(( @InetGetBytesRead * 100 ) / $FileSize))
GUICtrlDelete($txt3)
$txt3 = GUICtrlCreateLabel($percentage & "%", 15, 135)
GUICtrlSetBkColor ( $txt3 , $GUI_BKCOLOR_TRANSPARENT )
EndIf
Sleep(50)
$nMsg = GUIGetMsg()
Switch $nMsg
Case $ButtonStop
FileDelete("Install-Firefox.exe")
ExitLoop
Case $GUI_EVENT_CLOSE
Exit
EndSwitch
Wend
If (Int ((@InetGetBytesRead * 100 ) / $FileSize) = 100) Then
$percentage= (Int(( @InetGetBytesRead * 100 ) / $FileSize))
$txt3 = GUICtrlCreateLabel($percentage & "%", 15, 135)
GUICtrlSetBkColor ( $txt3 , $GUI_BKCOLOR_TRANSPARENT )
$i = TrayTip("Download Done!", "Firefox Download is complete!", 10 , 1)
GUICtrlSetData($Telecharger , "Install")
Else
$i = TrayTip("Download Aborted!", "Firefox Install has been removed!", 10)
EndIf
$temp = GUICtrlRead($Telecharger)
GUICtrlSetState($ButtonQuit, $GUI_SHOW)
GUICtrlSetState($Telecharger, $GUI_ENABLE)
GUICtrlSetState($ButtonStop, $GUI_HIDE)
GUICtrlDelete($txt3)
Sleep(1000)
Else
Run(@DesktopDir&"/Install-FireFox.exe")
WinWaitActive("Installation de Mozilla Firefox")
Sleep(300)
send("{ENTER}")
WinWaitActive("Installation de Mozilla Firefox","Accord de licence")
Sleep(300)
send("{TAB}")
send("{SPACE}")
send("{ENTER}")
WinWaitActive("Installation de Mozilla Firefox","Type d'installation")
Sleep(300)
send("{ENTER}")
WinWaitActive("Installation de Mozilla Firefox","Résumé")
Sleep(300)
send("{ENTER}")
WinWaitActive("Installation de Mozilla Firefox","Fin de l'assistant d'installation de Mozilla Firefox")
Sleep(300)
send("{ENTER}")
Sleep(300)
EndIf
Case $GUI_EVENT_CLOSE
ExitLoop
Case $ButtonQuit
ExitLoop
EndSwitch
WEnd