Code : Tout sélectionner
;
; AutoIt Version: 3.0
; Language: French
; Platform: WinXP
; Author: dug
;
; Script Function:
; téléchargement de vidéo sur leweb2zero.tv
;
#include <WinAPI.au3>
AutoItSetOption( "WinTitleMatchMode", 2 )
AutoItSetOption( "PixelCoordMode", 0 )
$block_input = 0 ; 1 ou 0
$rep_download = "C:\leweb2zero"
$bFirst = 1
Do
; *** recherche de la fenêtre "Mozilla Firefox" ***
$ret = WinWaitActive("Mozilla Firefox", "", 5000)
If ($ret = 0) Then
BlockInput(0)
MsgBox(0, "Erreur", "Erreur, fenêtre ""Mozilla Firefox"" non trouvé")
Exit 1
Else
If ($bFirst = 1) Then
BlockInput($block_input)
EndIf
EndIf
Send("{HOME}")
; *** récupère le titre de la vidéo ***
$titre = WinGetTitle("Mozilla Firefox")
$pos = StringInStr( $titre, "leweb2zero.tv - " )
If ($pos = 0) Then
BlockInput(0)
Exit
EndIf
$pos = StringInStr( $titre, " -- une autre télé" )
If ($pos <> 0) Then
$titre = StringLeft( $titre, $pos )
EndIf
$titre = StringMid( $titre, 16 )
; supprime les caractère impossible \ / : * ? " < > |
$titre = StringReplace( $titre, "\", "-" )
$titre = StringReplace( $titre, "/", "-" )
$titre = StringReplace( $titre, ":", ";" )
$titre = StringReplace( $titre, "*", "X" )
$titre = StringReplace( $titre, "?", "$" )
$titre = StringReplace( $titre, """", "''" )
$titre = StringReplace( $titre, "<", "{" )
$titre = StringReplace( $titre, ">", "}" )
$titre = StringReplace( $titre, "|", "I" )
;MsgBox(0, "titre", $titre)
;Sleep(500)
; *** recherche de la position du contrôle vidéo ***
$arr = WinGetPos("Mozilla Firefox")
$col_background = 0 ; fond noir
$x = 5
$y = 5
$col = 1
While $col <> $col_background
$col = PixelGetColor( $x , $y )
$y = $y +5
WEnd
;MouseClick("right", $arr[0] + $x, $arr[1] + $y)
;sleep(500)
;send("{ESC}")
$y_entete = 350 ; à recalculer par rapport à la résolution
$y = $y + $y_entete
$col = $col_background
While $col = $col_background
$col = PixelGetColor( $x , $y)
$x = $x +5
WEnd
$x = $x +10
; *** démarrage et arrêt de la vidéo ***
MouseClick("left", $arr[0] + $x, $arr[1] + $y)
Sleep(2000)
MouseClick("left", $arr[0] + $x, $arr[1] + $y)
;MouseClick("right", $arr[0] + $x, $arr[1] + $y)
;sleep(500)
;send("{ESC}")
Sleep(1000)
;Exit
; *** lancement du téléchargement ***
Send("{ALT}O")
Send("{UP}{RIGHT}{UP}{ENTER}") ; vérifier que la sélection est bien sur DownloadHelper
Sleep(100)
$ret = WinExists("A propos de DownloadHelper")
If ($ret = 1) Then
BlockInput(0)
Send("{ESC}")
MsgBox(0, "Erreur", "Erreur, pas de vidéo à télécharger")
Exit 2
EndIf
$ret = WinWaitActive("Sauvegarde du fichier", "", 5000)
If ($ret = 0) Then
BlockInput(0)
MsgBox(0, "Erreur", "Erreur, boite de dialogue ""Sauvegarde du fichier"" non trouvé")
Exit 3
EndIf
; *** positionne le bon répertoire ***
If ($bFirst = 1) Then
Send("{CTRL}C")
Sleep(50)
Send($rep_download)
Sleep(50)
Send("{ENTER}")
Sleep(50)
Send("{CTRL}V")
Sleep(50)
EndIf
; *** création du répertoire ***
Send("+{TAB}")
If ($bFirst = 0) Then
Send("{DEL}")
EndIf
Send("{APPSKEY}N{ENTER}")
Send($titre)
Send("{ENTER}{ENTER}")
; vérifier que la boite Téléchargement s'ouvre bien
Send("{TAB}{ENTER}")
; ferme la boite Téléchargement
$ret = WinWaitActive("Téléchargements", "", 500)
If ($ret <> 0) Then
Send("{ESC}")
EndIf
; *** sauvegarde de la page web ***
Send("{ALT}F")
Send("E")
$ret = WinWaitActive("Enregistrer sous", "", 5000)
If ($ret = 0) Then
BlockInput(0)
MsgBox(0, "Erreur", " Erreur, boite de dialogue ""Enregistrer sous""")
Exit 4
EndIf
; *** positionne le bon répertoire ***
If ($bFirst = 1) Then
Send("{CTRL}C")
Send($rep_download)
Send("{ENTER}")
Send("{CTRL}V")
EndIf
Send("{HOME}")
If ($bFirst = 0) Then
Send("..\")
EndIf
Send($titre)
Send("\{ENTER}")
; vérifier que page complète est sélectionné
Send("{ENTER}")
; ferme la boite Téléchargement
$ret = WinWaitActive("Téléchargements", "", 500)
If ($ret <> 0) Then
Send("{ESC}")
EndIf
; manque la création du fichier .url
; *** fermeture de l'onglet ***
Send("{ALT}F")
Send("F")
$bFirst = 0
Until 1