Page 1 sur 1

[R] Problème de chemin

Posté : mer. 20 mars 2013 18:08
par clark17
Bonjour à tous,

J'ai un petit problème avec ce script qui ne fonctionne pas comme il faut:

Code : Tout sélectionner

#include <GDIPlus.au3>

;Variables
$repetition = 5
$attente = 1 * 1000 * 20
$repertoire = @HOUR & "h" & @MIN & " " & @MDAY & "." & @MON & "." & @YEAR


;Création répertoire
DirCreate($repertoire & "\")

For $i = 001 To $repetition
    ;Télécharge en arrière plan
    Local $hDownload = InetGet("http://toto/map.jpg?0.314970187144354", $repertoire & "\map-" & StringFormat("%03i", $i) & ".jpg", 1, 1)
    Do
        Sleep(250)
    Until InetGetInfo($hDownload, 2)
    InetClose($hDownload)
    $img1 = $repertoire & "\map-" & StringFormat("%03i", $i) & ".jpg"  ; départ
    $img2 = $repertoire & "\map-" & StringFormat("%03i", $i) & ".jpg"  ; arrivée
    _RognerImage($img1, $img2, 5, 24, 991, 938)
    FileDelete($img1)
    Sleep($attente)
Next

MsgBox(0, "", "Fin du script")


Func _RognerImage($imga, $imgb, $X, $Y, $W, $H)
    Local $hImage, $hClone
    _GDIPlus_Startup ()
    $hImage = _GDIPlus_ImageLoadFromFile ($imga)
    $hClone = _GDIPlus_BitmapCloneArea ($hImage, $X, $Y, $W, $H, $GDIP_PXF32RGB)
    _GDIPlus_ImageSaveToFile($hClone, $imgb)
    _GDIPlus_ImageDispose($hClone)
    _GDIPlus_ImageDispose($hImage)
    _GDIPlus_ShutDown()
EndFunc

 
Il me crée bien le répertoire mais ne met plus rien dedans. Bien entendu le script marche bien si je met ca dans le même dossier.

@+

Re: [..] Problème de chemin

Posté : mer. 20 mars 2013 18:48
par GaRydelaMer
L'erreur vient de tes variables $img1 et $img2 qui ont la même valeur, le dossier est vide puisque tu fais un Fildelete() à la fin

Code : Tout sélectionner

#include <GDIPlus.au3>

;Variables
Local $repetition = 5, $attente = 1 * 1000 * 20, $hDownload, $imgTemp

; Pour le classement windows je préfère ca: 
Local $repertoire = @ScriptDir & "\" & StringFormat("%s.%02i.%02i %02ih %02i", @YEAR, @MON, @MDAY, @HOUR, @MIN) & "\"

;Création répertoire
DirCreate($repertoire)

$imgTemp = $repertoire & "mapTemp.jpg"
For $i = 1 To $repetition
    If FileExists($imgTemp) Then FileDelete($imgTemp)

    ;Télécharge en arrière plan
    $hDownload = InetGet("http://toto/map.jpg?0.314970187144354", $imgTemp, 1, 1)
    Do
        Sleep(250)
    Until InetGetInfo($hDownload, 2)
    InetClose($hDownload)

    _RognerImage($imgTemp, $repertoire & StringFormat("map-%03i.jpg", $i), 5, 24, 991, 938)
    Sleep($attente)
Next
If FileExists($imgTemp) Then FileDelete($imgTemp)

MsgBox(0, "", "Fin du script")

Func _RognerImage($Source, $Dest, $X, $Y, $W, $H)
    Local $hImage, $hClone
    _GDIPlus_Startup ()
    $hImage = _GDIPlus_ImageLoadFromFile ($Source)
    $hClone = _GDIPlus_BitmapCloneArea ($hImage, $X, $Y, $W, $H, $GDIP_PXF32RGB)
    _GDIPlus_ImageSaveToFile($hClone, $Dest)
    _GDIPlus_ImageDispose($hClone)
    _GDIPlus_ImageDispose($hImage)
    _GDIPlus_ShutDown()
EndFunc

Re: [..] Problème de chemin

Posté : mer. 20 mars 2013 19:21
par clark17
Le c.n!!! :oops:

Merci!