bobfii Posted December 11, 2013 Share Posted December 11, 2013 (edited) I am very new to autoit. I am trying to write a script that takes in parameters from the command line and simply displays the parameters in a message box. I think the code below should do that. local $parm1 = $CmdLine[1] local $parm2 = $CmdLine[2] local $message = $parm1 & $parm2 msgbox (0,"TEST", $message) Exit Then from the TOOLS menu I would like to use the GO command to run this script. But how can I include a couple of parameters in the GO command to test my script? Edited December 11, 2013 by bobfii Link to comment Share on other sites More sharing options...
BrewManNH Posted December 11, 2013 Share Posted December 11, 2013 Shift F8 in Scite, it will allow you to enter up to 4 command line arguements. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
jdelaney Posted December 11, 2013 Share Posted December 11, 2013 (edited) You can also call it through CMD prompt (where CD is the directory of the script, else write out the full path to .au3 file) "%programfiles(x86)%autoit3autoit3.exe" test.au3 testParam1 testParam2 Or, compile the script, and then on command line, remove this: "%programfiles(x86)%autoit3autoit3.exe" If your 'Path' env var includes the autoit programs dir, than just call autoit3.exe test.au3 testParam1 testParam2 full list of options in helpfile, under Command Line Parameters Edited December 11, 2013 by jdelaney IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window. Link to comment Share on other sites More sharing options...
bobfii Posted December 11, 2013 Author Share Posted December 11, 2013 Thanks to both of you for the help. I added two parameters using the shift F8 mode, then when ran the code I get this error: local $parm1 = $CmdLine[1] local $parm1 = ^ ERROR According to the help file $CmdLine is a special array initialized with the command line parameters passed in to your AutoIt script. What have I missed? Link to comment Share on other sites More sharing options...
Developers Jos Posted December 11, 2013 Developers Share Posted December 11, 2013 Show the SciTE outputpane info so we can see if the parameters are showing. Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
bobfii Posted December 11, 2013 Author Share Posted December 11, 2013 >"C:Program Files (x86)AutoIt3SciTE..autoit3.exe" /ErrorStdOut "C:\Program Files (x86)\AutoIt3\Examples\test.au3" C:\Program Files (x86)\AutoIt3\Examples\test.au3 (4) : ==> Array variable has incorrect number of subscripts or subscript dimension range exceeded.: local $parm1 = $CmdLine[1] local $parm1 = ^ ERROR >Exit code: 1 Time: 1.651 Link to comment Share on other sites More sharing options...
Developers Jos Posted December 11, 2013 Developers Share Posted December 11, 2013 As I expected, it isn't inserting the Parameters. Update your SciTE installation to the Full SciTE installer so you have the latest editor plus all extra options. Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
bobfii Posted December 11, 2013 Author Share Posted December 11, 2013 OK and thanks. I'll do that now. Link to comment Share on other sites More sharing options...
BrewManNH Posted December 11, 2013 Share Posted December 11, 2013 You aren't sending any command line parameters, you should see something like this "E:BetaAppSciTEAutoIt3WrapperAutoIt3Wrapper.exe" /run /prod /ErrorStdOut /in "E:AutoItScriptstest.au3" /UserParams test 1 2 test, 1 and 2 are the parameters I set. Also, you should test to see if any parameters are passed prior to trying to use them. If $CmdLine[0] > 0 Then local $parm1 = $CmdLine[1] local $parm2 = $CmdLine[2] Endif If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
bobfii Posted December 11, 2013 Author Share Posted December 11, 2013 Thanks.As I said, I am new to autoit.This is all very good information and I greatly appreciate the quick response Link to comment Share on other sites More sharing options...
jdelaney Posted December 11, 2013 Share Posted December 11, 2013 (edited) I'd do something like this (I prefer Enums), to make sure everything functions smoothly (covers all potential scenarios where errors can occur)...then in the script, drive everything off the array: #include <Array.au3> Global Enum $giParam_1,$giParam_2,$giParam_UBound Global $aParams[$giParam_UBound] For $i = 1 to UBound($CmdLine)-1 If $i > $giParam_UBound Then MsgBox(1,1,"More Params included than expected") ExitLoop EndIf $aParams[$i-1]=$CmdLine[$i] Next _ArrayDisplay($aParams) MsgBox(1,1,"First param " & $aParams[$giParam_1]) MsgBox(1,1,"Second param " & $aParams[$giParam_2]) Adding new params is as easy as adding a variable to the Global Enum, just prior to $giParam_UBound Edit: you would make the enum variable names specific to what you expect them to be...I just provided samples as the count of the variable. Edit2: missed this line: #include <Array.au3> Edited December 11, 2013 by jdelaney IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window. Link to comment Share on other sites More sharing options...
Solution bobfii Posted December 11, 2013 Author Solution Share Posted December 11, 2013 Wow....ok that's a little over my head. I can follow most of your script but I really don't understand ENUM. But that's ok as this will be a good way to learn the language and the tools.I'll go thru your script and use the F1 help key on all the items I don't understand.Is there any kind of breakpoint or real time variable "watch window" in the tools?As I have just downloaded the full install of SciTE I'll spend some time reading it's help file.Thanks for all the information. This should keep me busy for awhile Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now