[R] Double run + fichier passé en paramètre au lancement

Aide et conseils concernant AutoIt et ses outils.
Règles du forum
.
Répondre
Avatar du membre
martinbrait
Niveau 4
Niveau 4
Messages : 55
Enregistré le : ven. 06 mars 2009 17:17
Status : Hors ligne

[R] Double run + fichier passé en paramètre au lancement

#1

Message par martinbrait »

Bonjour,

Je cherche à exécuter une application autoit de ma fabrication, en utilisant un double run:

:arrow: soit je démarre mon programme avec un double clic,
et mon appli lance une routine 1 sans paramètre,

:arrow: soit je fais un glisser-déposer de fichier sur l'icône de l'exe de mon appli, et mon programme exécute une routine 2, en passant mon fichier en paramètre.

Problème, j'ai longtemps lu les fichiers d'aide mais je ne comprends rien du tout. :? Mon niveau est bien trop faible pour que je sache créer le code. On me conseille de chercher vers ProgramParameters... mais je ne trouve rien! Il me faudrait un exemple que je puisse tester, en [blink]copier coller[/blink] sous autoit.
Merci d'avance!
Modifié en dernier par martinbrait le ven. 24 juil. 2009 01:06, modifié 2 fois.
Avatar du membre
orax
Modérateur
Modérateur
Messages : 1479
Enregistré le : lun. 23 mars 2009 04:50
Localisation : ::1
Status : Hors ligne

Re: DOUBLE RUN + PASSER UN FICHIER EN PARAMETRE AU LANCEMENT

#2

Message par orax »

Bonsoir, dans Autoit les paramètres sont stockés dans la variable $CmdLine. Soit $CmdLine[1] pour le premier paramètre.
De petits détails peuvent faire toute la différence. — Quand la boule de neige commence à rouler… poussez-la. (Columbo)
Avatar du membre
martinbrait
Niveau 4
Niveau 4
Messages : 55
Enregistré le : ven. 06 mars 2009 17:17
Status : Hors ligne

Re: DOUBLE RUN + PASSER UN FICHIER EN PARAMETRE AU LANCEMENT

#3

Message par martinbrait »

Voici l'aide d'autoit sur le sujet, mais je suis absolument incapable de l'utiliser! :cry:

Command Line Parameters
The special array $CmdLine is initialized with the command line parameters passed in to your AutoIt script. Note the scriptname is not classed as a parameter; get this information with @ScriptName instead. A parameter that contains spaces must be surrounded by "double quotes". Compiled scripts accept command line parameters in the same way.

$CmdLine[0] is number of parameters
$CmdLine[1] is param 1 (after the script name)
$CmdLine[2] is param 2 etc
...
$CmdLine[$CmdLine[0]] is one way to get the last parameter...



So if your script is run like this:

AutoIt3.exe myscript.au3 param1 "this is another param"

$CmdLine[0] equals... 2

$CmdLine[1] equals... param1

$CmdLine[2] equals... this is another param

@ScriptName equals... myscript.au3



In addition to $CmdLine there is a variable called $CmdLineRaw that contains the entire command line unsplit, so for the above example:

$CmdLineRaw equals... myscript.au3 param1 "this is another param"



If the script was compiled it would have been run like this:

myscript.exe param1 "this is another param"

$CmdLineRaw equals... param1 "this is another param"

Note that $CmdLineRaw just return the parameters.



Note : only 63 parameters can be return by $CmdLine[...], but $CmdLineRaw will always returns the entire command line.



AutoIt specific command Line Switches
Form1: AutoIt3.exe [/ErrorStdOut] [/AutoIt3ExecuteScript] file [params ...]
Execute an AutoIt3 Script File


/ErrorStdOut Allows to redirect fatal error to StdOut which can be captured by an application as Scite editor. This switch can be used with a compiled script.


To execute a standard AutoIt Script File 'myscript.au3', use the command:
'AutoIt3.exe myscript.au3'



Form2: Compiled.exe [/ErrorStdOut] [params ...]
Execute an compiled AutoIt3 Script File produced with Aut2Exe.

Form3: Compiled.exe [/ErrorStdOut] [/AutoIt3ExecuteScript file] [params ...]
Execute another script file from a compiled AutoIt3 Script File. Then you don't need to fileinstall another copy of AutoIT3.exe in your compiled file.


Form4: AutoIt3.exe [/ErrorStdOut] /AutoIt3ExecuteLine "command line"
Execute one line of code.

To execute a single line of code, use the command:
Run(@AutoItExe & ' /AutoIt3ExecuteLine "MsgBox(0, ''Hello World!'', ''Hi!'')"')

The tray icon will not be displayed when using /AutoIt3ExecuteLine

NOTE: Correct usage of single- and double- quotation marks is important, even double single.
Modifié en dernier par martinbrait le ven. 24 juil. 2009 01:06, modifié 1 fois.
Avatar du membre
orax
Modérateur
Modérateur
Messages : 1479
Enregistré le : lun. 23 mars 2009 04:50
Localisation : ::1
Status : Hors ligne

Re: DOUBLE RUN + PASSER UN FICHIER EN PARAMETRE AU LANCEMENT

#4

Message par orax »

Ca pourrait donner quelque chose dans ce genre :

Code : Tout sélectionner

If $CmdLine[0] = 0 Then
    MsgBox(0, "", "Routine 1")
Else
    MsgBox(0, "", "Routine 2" & @CRLF & $CmdLine[1])
EndIf
De petits détails peuvent faire toute la différence. — Quand la boule de neige commence à rouler… poussez-la. (Columbo)
Avatar du membre
martinbrait
Niveau 4
Niveau 4
Messages : 55
Enregistré le : ven. 06 mars 2009 17:17
Status : Hors ligne

Re: DOUBLE RUN + PASSER UN FICHIER EN PARAMETRE AU LANCEMENT

#5

Message par martinbrait »

MERCI ET BRAVO ORAX! CETTE REPONSE RESOUT PARFAITEMENT MON PROBLEME!
Répondre