[R] Problème de chemin

Aide et conseils concernant AutoIt et ses outils.
Règles du forum
.
Répondre
clark17
Niveau 4
Niveau 4
Messages : 70
Enregistré le : ven. 23 sept. 2011 02:12
Status : Hors ligne

[R] Problème de chemin

#1

Message 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.

@+
GaRydelaMer
Niveau 7
Niveau 7
Messages : 450
Enregistré le : mer. 18 mars 2009 22:12
Localisation : Montpellier
Status : Hors ligne

Re: [..] Problème de chemin

#2

Message 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
clark17
Niveau 4
Niveau 4
Messages : 70
Enregistré le : ven. 23 sept. 2011 02:12
Status : Hors ligne

Re: [..] Problème de chemin

#3

Message par clark17 »

Le c.n!!! :oops:

Merci!
Répondre