Jump to content

command line flags


Orangey
 Share

Recommended Posts

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.

Link to comment
Share on other sites

  • Developers

this is similar to the original commandline:

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

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

Would this work ?

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


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

Link to comment
Share on other sites

  • Moderators

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.

Link to comment
Share on other sites

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


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

Link to comment
Share on other sites

  • Moderators

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.

Link to comment
Share on other sites

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 & '"')
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...