Page 1 sur 1

[R] Automatiser l'enregistrement d'un fichier telechargé

Posté : mer. 07 janv. 2015 15:57
par danieller
Automatiser l'enregistrement d'un fichier

Bonjour, je cherche actuellement a automatiser l'enregistrement d'un fichier (de façon hebdomadaire). Je suis actuellement en phase de test et de réapprentissage (car cela fait 5 ans que je n'ai plus utilisé AutoIt).

Bref, j'ai un bout de code qui fonctionne partiellement, mais je ne sais pas ce qui bloque : tempo ? ou commandes ? J'aurai voulu faire un ALT + R pour remplacer LEFT + ENTER , mais bon.

Merci pour l'aide que vous pourrez m'apporter.
A noter que j'ai consulter le forum avant de poster ce sujet... cela m'a aidé mais n'a pas complétement répondu à ma problématique.

Code : Tout sélectionner


#include <IE.au3>

Local $oIE = _IECreate("https://www.autoitscript.com/cgi-bin/getfile.pl?autoit3/autoit-v3-setup.exe")
Sleep(4000)
Send("{ALT}")
Send("{ALT}")
Sleep(5000)
Send("{ALT}")
Send("{LEFT}")
Send("{ENTER}")

 

Re: Automatiser l'enregistrement d'un fichier telechargé

Posté : mer. 07 janv. 2015 16:45
par Y01
Bonjour,

Pour effectuer un ALT+R, il faut faire
Pour le reste, je n'ai pas bien compris la demande.

PS1 : Pour télécharger un fichier, il faut utiliser InetGet

PS2 : [..] doit être placer dans le titre du sujet ;)

Re: Automatiser l'enregistrement d'un fichier telechargé

Posté : mer. 07 janv. 2015 16:50
par DimVar
Bonjour,

Vous devez modifier votre titre en éditant votre premier message.
De quel enregistrement parlez-vous ? Quel est le contexte ? Éventuellement environnement...
Ou se trouve le fichier ?

Cdlt, Dimvar.

Re: Automatiser l'enregistrement d'un fichier telechargé

Posté : mer. 07 janv. 2015 17:03
par danieller
Merci pour vos réponses,

en fait je souhaite enregistrer un fichier internet, peu importe le type de fichier, je souhaite être capable de gérer une fenêtre qui s'ouvre et qui demande d'enregistrer un fichier (j’espère être assez clair dans la description).
Le truc c'est que mon code ne marche pas très bien... je vais essayer avec le !R

Merci.

Re: [..] Automatiser l'enregistrement d'un fichier telecharg

Posté : mer. 07 janv. 2015 17:04
par DimVar
Y01, je passe mon tour... :lol:

Re: [..] Automatiser l'enregistrement d'un fichier telecharg

Posté : mer. 07 janv. 2015 17:15
par jguinch
Tu as regardé du côté de InetGet ?

Re: [..] Automatiser l'enregistrement d'un fichier telecharg

Posté : mer. 07 janv. 2015 19:15
par danieller
Oui InetGet ça marche assez bien, par contre petite question subsidiaire, le fichier est enregistré dans les fichiers temporaires sur l'exemple suivant :

Comment faire pour l'enregistrer sur le bureau ?? Merci.

Code : Tout sélectionner

#include <InetConstants.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    ; Save the downloaded file to the temporary folder.
    Local $sFilePath = @TempDir & "\update.dat"

    ; Download the file in the background with the selected option of 'force a reload from the remote site.'
    Local $hDownload = InetGet("http://www.autoitscript.com/autoit3/files/beta/update.dat", @TempDir & "\update.dat", $INET_FORCERELOAD, $INET_DOWNLOADBACKGROUND)

    ; Wait for the download to complete by monitoring when the 2nd index value of InetGetInfo returns True.
    Do
        Sleep(250)
    Until InetGetInfo($hDownload, $INET_DOWNLOADCOMPLETE)

    ; Retrieve details about the download file.
    Local $aData = InetGetInfo($hDownload)
    If @error Then Return SetError(1, 0, FileDelete($sFilePath)) ; If an error occurred the return from the function and delete the file.

    ; Close the handle returned by InetGet.
    InetClose($hDownload)

    ; Display details about the downloaded file.
    MsgBox($MB_SYSTEMMODAL, "", "Bytes read: " & $aData[$INET_DOWNLOADREAD] & @CRLF & _ ; Or use 0 instead of the constant.
            "Size: " & $aData[$INET_DOWNLOADSIZE] & @CRLF & _ ; Or use 1 instead of the constant.
            "Complete: " & $aData[$INET_DOWNLOADCOMPLETE] & @CRLF & _ ; Or use 2 instead of the constant.
            "successful: " & $aData[$INET_DOWNLOADSUCCESS] & @CRLF & _ ; Or use 3 instead of the constant.
            "@error: " & $aData[$INET_DOWNLOADERROR] & @CRLF & _ ; Or use 4 instead of the constant.
            "@extended: " & $aData[$INET_DOWNLOADEXTENDED] & @CRLF) ; Or use 5 instead of the constant.

    ; Delete the file.
    FileDelete($sFilePath)
EndFunc   ;==>Example


 

Re: [..] Automatiser l'enregistrement d'un fichier telecharg

Posté : mer. 07 janv. 2015 19:17
par jguinch
Tu as consulté le forum, mais pas la doc... :roll:
Regarde dans la doc la section Macro Reference

Re: [..] Automatiser l'enregistrement d'un fichier telecharg

Posté : mer. 07 janv. 2015 20:23
par danieller
Oui je regarde aussi en parallèle (mais c'est pas super "implicite" ..), bref,
je remplace le @tempdir par @MyDocumentsDir et ça marche aussi .... il doit donc exister un truc du genre : "MyDesktopDir" je pense...

Merci,
Bonne soirée...

Re: [..] Automatiser l'enregistrement d'un fichier telecharg

Posté : mer. 07 janv. 2015 20:42
par orax
http://www.autoitscript.fr/autoit3/docs/macros.htm

Code : Tout sélectionner

@DesktopCommonDir ; Chemin vers Bureau.
@DesktopDir ; Chemin vers le bureau de l'utilisateur courant.

Re: [..] Automatiser l'enregistrement d'un fichier telecharg

Posté : mer. 07 janv. 2015 21:32
par danieller
Ah ah ah !! j'étais pas loin !!!

Merci pour tout !!

Re: [..] Automatiser l'enregistrement d'un fichier telecharg

Posté : mer. 07 janv. 2015 21:38
par jguinch
Merci de passer le sujet en [R] si le problème est résolu. :wink:

Re: [R] Automatiser l'enregistrement d'un fichier telechargé

Posté : mer. 07 janv. 2015 22:23
par danieller
Merci à tous, ça fait super plaisir de pouvoir rapidement solutionner des petits problèmes...