Jump to content
Sign in to follow this  
Orangey

command line flags

Recommended Posts

Orangey

I'm having trouble understanding how to pass flags like -p -q etc. to the command line with autoit.

This code works for me:

RunWait('"C:\Repeater\oggenc2.exe" "-q 5" "C:\Repeater\test.wav"')

But, what I'd like to do is to specify the 5 in there and the path to the .wav file as variables that can be changed around. So something like this:

RunWait('"C:\Repeater\oggenc2.exe" "-q " &$var1 &$var2')

Do the $cmdline[] variables have something to do with this? I'd appreciate anyone's help in explaining this to me.

Share this post


Link to post
Share on other sites
BigDod

Would this work ?

RunWait("C:\Repeater\oggenc2.exe -q " & $var1 & " " & $var2)


Get Beta versions Here Get latest SciTE editor Here AutoIt 1-2-3 by Valuater - A great starting point.

Time you enjoyed wasting is not wasted time ......T.S. Elliot
Suspense is worse than disappointment................Robert Burns
God help the man who won't help himself, because no-one else will...........My Grandmother

Share this post


Link to post
Share on other sites
SmOke_N

Does this work?

This basically breaks your line down:
RunWait('"C:\Repeater\oggenc2.exe"' & " " & '"-q ' & $var1 & '" ' & '"' & $var2 & '"')

This is probably all you need:
RunWait('"C:\Repeater\oggenc2.exe"' & ' ' & '-q ' & $var1 & ' ' & $var2)

Maybe the above can explain it to you.  Happy Holidays!

Edit

Damn... Too slow!! He's much better at the command line parameters than I am, and his is a bit better at the beginning... Mine has an unnecessary & " " & RunWait('"C:\Repeater\oggenc2.exe"' & ' ' & '-q ' ... that could have just been wrapped as he showed: RunWait("C:\Repeater\oggenc2.exe -q "

Edited 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.

Share this post


Link to post
Share on other sites
BigDod

Does this work?

This basically breaks your line down:
RunWait('"C:\Repeater\oggenc2.exe"' & " " & '"-q ' & $var1 & '" ' & '"' & $var2 & '"')

This is probably all you need:
RunWait('"C:\Repeater\oggenc2.exe"' & ' ' & '-q ' & $var1 & ' ' & $var2)

Maybe the above can explain it to you.  Happy Holidays!
Please explain the single and double quotes round C:\Repeater\oggenc2.exe


Get Beta versions Here Get latest SciTE editor Here AutoIt 1-2-3 by Valuater - A great starting point.

Time you enjoyed wasting is not wasted time ......T.S. Elliot
Suspense is worse than disappointment................Robert Burns
God help the man who won't help himself, because no-one else will...........My Grandmother

Share this post


Link to post
Share on other sites
SmOke_N

They were on his example that worked, I was merely adding them in when I was looking at his example and typing.


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.

Share this post


Link to post
Share on other sites
Orangey

Awesome, thanks guys, happy holidays!

This one worked for me:

RunWait('"C:\Repeater\oggenc2.exe"' & ' ' & '-q ' & $var1 & ' ' & $var2)

:P

Share this post


Link to post
Share on other sites
JerryD

Awesome, thanks guys, happy holidays!

This one worked for me:

RunWait('"C:\Repeater\oggenc2.exe"' & ' ' & '-q ' & $var1 & ' ' & $var2)
You should probably use this:

RunWait('"C:\Repeater\oggenc2.exe"' & ' ' & '-q ' & $var1 & ' "' & $var2 & '"')

If you don't and $var2 has a space in the filename, it will fail since it will try to parse the second paramater incorrectly. With the first code sample, if the $var2 is equal to C:\Documents and Settings\All Users\Documents\Test.wav and $var1 = 5, oggen2.exe will see C:\Documents as the second parameter.

In fact, if oggen2 is an AutoIt script, in your original example, AutoIt parses out the command line

RunWait('"C:\Repeater\oggenc2.exe" "-q 5" "C:\Repeater\test.wav"')

Cmdline[1] = "-q 5" and Cmdline[2] = "C:\Repeater\test.wav" (note that the variables do NOT contain quotes). However, even with my suggested code, it would parse out:

Cmdline[1] = "-q", Cmdline[2]=5 and Cmdline[3] = "C:\Repeater\test.wav" If you want the second parameter to be "-q 5", then you should use:

RunWait('"C:\Repeater\oggenc2.exe"' & ' "' & '-q ' & $var1 & '" "' & $var2 & '"')

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×