Garret Picchioni Posted July 6, 2007 Posted July 6, 2007 (edited) Hi, I'm not sure if this is possible, I did some searching around and found $CmdLine[], but I'm not sure if this is what I'm looking for or not. But I'm trying to pass a bunch of command line switches into one of my AutoIt scripts. I basically have a basic few lines of code along with a couple of functions, and I'd like my script to only execute the code within these functions if that specific command line parameter is passed. So if I have The following as my code InetGet("www.bla.com/test.exe") If $foo = 1 Then FileRemove("C:\test.exe") EndIf Func $receive() . . . EndFunc Func $download() . . . EndFunc Func $test() . . . EndFunc and I execute my script as follows: myscript.exe /download /test I only want the code before my functions to be executed as well as the code within the $download() and $test() functions leaving the code within the $receive() function omitted. I hope this makes sense, I'm working on little sleep Thanks in advanced. Edited July 6, 2007 by Garret Picchioni
Moderators SmOke_N Posted July 6, 2007 Moderators Posted July 6, 2007 (edited) Put the following in a script and compile it: If $cmdline[0] Then For $iCC = 1 To $cmdline[0] MsgBox(64, '$cmdline[' & $iCC & ']', $cmdline[$iCC]) Next Else MsgBox(16, 'Error', 'No command line was passed.') EndIf Edited July 6, 2007 by SmOke_N Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.
PsaltyDS Posted July 6, 2007 Posted July 6, 2007 (edited) Try this as a demo: If $CmdLine[0] Then For $n = 1 To $CmdLine[0] Switch $CmdLine[$n] Case "/receive" _Receive() Case "/download" _Download() Case "/test" _Test() EndSwitch Next EndIf Func _Receive() MsgBox(64, "Receive", "Receive function called...") EndFunc ;==>_Receive Func _Download() MsgBox(64, "Download", "Download function called...") EndFunc ;==>_Download Func _Test() MsgBox(64, "Test", "Test function called...") EndFunc ;==>_Test Notice that functions are not variables and do not start with '$'. The underscore in the function names is just a common convention to indicate a user defined (vice built-in) function and is not required. Edit: Drat! SmOked again by the answer-bot! Edited July 6, 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
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