sandman Posted May 3, 2007 Posted May 3, 2007 Is it possible to set options for commandline? For example, compiled Au3 script au3.exe will create a folder when this command is given in CMD:C:\> au3.exe create folder SHWEETIs it possible to have AutoIt interpret this and know what to do? I am not asking about how to interpret it, but rather if it is capable of responding to a command like this at all. [center]"Yes, [our app] runs on Windows as well as Linux, but if you had a Picasso painting, would you put it in the bathroom?" -BitchX.com (IRC client)"I would change the world, but they won't give me the source code." -Unknownsite . blog . portfolio . claimidcode.is.poetry();[/center]
tAKTelapis Posted May 3, 2007 Posted May 3, 2007 (edited) Yes.. it is. I forget how, but i am reasonably sure it is. *EDIT* worked it out (this should have its own section in the helpfile) Search the helpfile (or forums) for $cmdline its all there. Cheers /tAK *EDIT 2* for the sake of trying it out myself, here is a basic, crude example: select case $cmdline[0] = 0 ; check to see if there is a parameter msgbox(0, "No Param", "Please specify start or end") Case $cmdline[1] = 'start' ; if parameter is start msgbox(0, "Start", "it has begun") Case $cmdline[1] = 'end' ; if parameter is end msgbox(0, "End", "all done") Case Else ; if parameter is other msgbox(0, "No Param", "Please specify start or end") EndSelect Exit Edited May 3, 2007 by tAKTelapis
sandman Posted May 3, 2007 Author Posted May 3, 2007 Okay, thanks very much. One more thing: Is there a way to have it print (or echo or whatever it is called in CMD) text when a command is given? Say, 'au3 eat pie'.If $cmdline[0] > 0 And $cmdline[1] = "eat" And $cmdline[2] = "pie" Then MadeUpFunction("ECHOTHISBACK!!!") EndIfSo that it would look like this in CMD:C:\> au3 eat pie ECHOTHISBACK!!! C:\> [center]"Yes, [our app] runs on Windows as well as Linux, but if you had a Picasso painting, would you put it in the bathroom?" -BitchX.com (IRC client)"I would change the world, but they won't give me the source code." -Unknownsite . blog . portfolio . claimidcode.is.poetry();[/center]
Shevilie Posted May 3, 2007 Posted May 3, 2007 328 post... and you havent checked the helpfile...http://www.autoitscript.com/autoit3/docs/i...htm#CommandLine Start here if you are new Valuater's AutoIT 1-2-3Looking for an UDF - Look hereDo you need to do it twice - Autoit
Administrators Jon Posted May 3, 2007 Administrators Posted May 3, 2007 Okay, thanks very much. One more thing: Is there a way to have it print (or echo or whatever it is called in CMD) text when a command is given? Say, 'au3 eat pie'.If $cmdline[0] > 0 And $cmdline[1] = "eat" And $cmdline[2] = "pie" Then MadeUpFunction("ECHOTHISBACK!!!") EndIfSo that it would look like this in CMD:C:\> au3 eat pie ECHOTHISBACK!!! C:\>No, AutoIt is a Windows program so it can't output to the cmd console like that. Deployment Blog:Â https://www.autoitconsulting.com/site/blog/ SCCM SDK Programming:Â https://www.autoitconsulting.com/site/sccm-sdk/
sandman Posted May 3, 2007 Author Posted May 3, 2007 328 post... and you havent checked the helpfile...http://www.autoitscript.com/autoit3/docs/i...htm#CommandLineI've already seen that, I was asking for a different thing. Thanks, though.@Jon: Well, would it be able to get what other programs return? Like if I called a program through ShellExecute, is there a way to get how it echoes back? [center]"Yes, [our app] runs on Windows as well as Linux, but if you had a Picasso painting, would you put it in the bathroom?" -BitchX.com (IRC client)"I would change the world, but they won't give me the source code." -Unknownsite . blog . portfolio . claimidcode.is.poetry();[/center]
PsaltyDS Posted May 3, 2007 Posted May 3, 2007 I've already seen that, I was asking for a different thing. Thanks, though.@Jon: Well, would it be able to get what other programs return? Like if I called a program through ShellExecute, is there a way to get how it echoes back?Check out the options in Run() and RunWait() for $STDOUT_CHILD, $STDIN_CHILD, and $STDERR_CHILD combined with StdOutRead(), etc.All of which is... wait for it... in the help file! Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
AcidCorps Posted June 4, 2007 Posted June 4, 2007 is there a way to us variables in the switch, for example script.au3 /uninstall 123 would return setup.exe /uninstall 123 at the same time as script.au3 /uninstall 456 setup.exe /uninstall 456 or would I have to write out every possible switch?
PsaltyDS Posted June 4, 2007 Posted June 4, 2007 (edited) is there a way to us variables in the switch, for example script.au3 /uninstall 123 would return setup.exe /uninstall 123 at the same time as script.au3 /uninstall 456 setup.exe /uninstall 456 or would I have to write out every possible switch? Huh...? The $CmdLine array contains the parameters from the command line. So in your first example: $CmdLine[0] = 2 $CmdLine[1] = "/uninstall" $CmdLine[2] = "123" You can refer to $CmdLine[2] throughout your entire script. Is that what you meant? Edit: Oops, CmdLine, not CommandLine... :"> Edited June 4, 2007 by PsaltyDS Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
herewasplato Posted June 4, 2007 Posted June 4, 2007 sandman,I'm not sure what you want - look at this:http://www.autoitscript.com/forum/index.ph...showtopic=37626or search title only for console in the example scripts...sorry so late [size="1"][font="Arial"].[u].[/u][/font][/size]
sandman Posted June 4, 2007 Author Posted June 4, 2007 sandman, I'm not sure what you want - look at this: http://www.autoitscript.com/forum/index.ph...showtopic=37626 or search title only for console in the example scripts... sorry so lateLol, a resurrection! Thanks, but I am asking how to interpret commands from a CMD window, not make windows and input into them. I have figured out a solution for responding to commands, though, and here is an example:If $cmdline[0] > 0 Then If $cmdline[1] = "talk" Then $bat = "echo ""Hello World""" FileWrite("respond.bat", $bat) If Not @error Run("respond.bat") EndIf EndIf [center]"Yes, [our app] runs on Windows as well as Linux, but if you had a Picasso painting, would you put it in the bathroom?" -BitchX.com (IRC client)"I would change the world, but they won't give me the source code." -Unknownsite . blog . portfolio . claimidcode.is.poetry();[/center]
November Posted June 5, 2007 Posted June 5, 2007 Just an idea... Just do a sticky post with that Cheers Old Scriptology Visual Ping 1.8 - Mass Ping Program with export to txt delimited. Desktop 2 RGB and YMCK - Pick a color in the desktop and get the RGB and YMCK code. Desktop 2 RGB - Pick a color in the desktop and get the RGB code. ShootIT 1.0 - Screen Capture full and partial screen [font="'Arial Black';"]Remember Remember The Fifth of November.[/font]
DaveF Posted June 5, 2007 Posted June 5, 2007 I'm not sure what the original poster's task really is, but this will work unless the comsumer of the script literally is a user typing in a DOS box... ; Test to see if there was a command line argument, if not insert a placeholder If $cmdline[0] Then $firstArg = $cmdline[1] Else $firstArg = "(not present)" EndIf ; Perform some operation MsgBox(0, "Test", "The 1st argument on the command line was: " & $firstArg) ; Write a message to the console ConsoleWrite("Writing " & $firstArg & " on STDOUT (but that doesn't mean that Windows will let you see it...)" & @CRLF) Yes yes yes, there it was. Youth must go, ah yes. But youth is only being in a way like it might be an animal. No, it is not just being an animal so much as being like one of these malenky toys you viddy being sold in the streets, like little chellovecks made out of tin and with a spring inside and then a winding handle on the outside and you wind it up grrr grrr grrr and off it itties, like walking, O my brothers. But it itties in a straight line and bangs straight into things bang bang and it cannot help what it is doing. Being young is like being like one of these malenky machines.
sandman Posted June 5, 2007 Author Posted June 5, 2007 unless the comsumer of the script literally is a user typing in a DOS box...-snip-lol, that's what I meant this whole time, so that the user will be in CMD (same as Run>cmd) and type: myscript.exe dosomething. AutoIt will interpret the dosomething command as a command to respond, and then write and execute a batch file to respond.@november: I'll post it in Example Scripts, see what happens [center]"Yes, [our app] runs on Windows as well as Linux, but if you had a Picasso painting, would you put it in the bathroom?" -BitchX.com (IRC client)"I would change the world, but they won't give me the source code." -Unknownsite . blog . portfolio . claimidcode.is.poetry();[/center]
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