Code : Tout sélectionner
#cs ----------------------------------------------------------------------------
AutoIt Version: 3.3.8.1
Author: Scriptator
Script Function:
Download & install the latest version of notepad++.
#ce ----------------------------------------------------------------------------
; Script Start - Add your code below here
#include <Math.au3>
#Include <String.au3>
#Include <INET.au3>
Local $answer = MsgBox(4, "Installation automatique de Notepad++", "Ce programme va télécharger et installer la dernière version de Notepad++" & @CRLF & "Voulez-vous continuer ?")
If $answer = 7 Then
Exit
EndIf
; Extraction de la version actuelle
$extract = _StringBetween(_INetGetSource('http://notepad-plus-plus.org/download/'), '<h1>v', ' - current version</h1>')
$version = $extract[0]
$notepad = 'npp.' & $version & '.Installer.exe'
$_FinalUrl = 'http://download.tuxfamily.org/notepadplus/'& $version & '/' & $notepad
$_TempPath = @TempDir & '\' & $notepad
$_FileSize = InetGetSize ( $_FinalUrl )
$_Gui = GUICreate ("Téléchargement de " & $notepad, 330, 52, 363, 252)
$_ProgressBar = GUICtrlCreateProgress (0, 0, 325, 25)
GUISetState (@SW_SHOW)
$_Download = InetGet ( $_FinalUrl, $_TempPath, 1, 1 )
Local $_InfoData
Do
$_InfoData = InetGetInfo ( $_Download )
If Not @error Then
$_InetGet = $_InfoData[0]
$_DownloadPercent = Round ( ( 100 * $_InetGet ) / $_FileSize )
$_DownloadPercent = _Min ( _Max ( 1, $_DownloadPercent ), 99 )
GUICtrlSetData ( $_ProgressBar, $_DownloadPercent )
$_Label = GUICtrlCreateLabel ( $_DownloadPercent & ' %', 5, 25, 350, 20 )
EndIf
Sleep ( 100 )
Until $_InfoData[2] = True
$_Label = GUICtrlCreateLabel ( 'Téléchargement terminé', 5, 25, 350, 20 )
;On ferme la barre de progression (téléchargement terminé)
GUIDelete ($_Gui)
; Lancement de l'install auto
Run(@TempDir & '\' & $notepad)
WinWaitActive("Installer Language")
Send("{ENTER}")
WinWaitActive("Installation de Notepad++")
Send("!s")
WinWaitActive("Installation de Notepad++","Licence utilisateur")
Send("!c")
WinWaitActive("Installation de Notepad++","Choisissez le dossier d'installation")
Send("!s")
WinWaitActive("Installation de Notepad++","Choisissez les composants")
Send("!s")
WinWaitActive("Installation de Notepad++","%APPDATA%")
Send("!i")
if WinExists("Installation de Notepad++","stability issue") Then
Send("{ENTER}")
EndIf
WinWaitActive("Installation de Notepad++","Fin de l'installation ")
Send("!f")
WinWaitActive("C:\Program Files\Notepad++\change.log - Notepad++")
MsgBox(64,"Fin de l'installation","Installation terminée !")
WinKill("C:\Program Files\Notepad++\change.log - Notepad++")