Sign in to follow this  
Followers 0
MikeK6MKF

Understanding The AutoIt Run Command Structure

9 posts in this topic

Hi Gang,

I am the newest of AutoIt scripting newbies.  I just downloaded AutoIt yesterday and am building a prototype of an application.

I have my GUI working pretty well with placeholder statements in each Case statement.

What I am seeking advice on is how to translate the following Windows command line instruction into AutoIt Run syntax:

start AcroRd32.exe /A "page=7" "C:UsersMike-K6MKFDesktopK6TU Predictions_K6MKF MAR 2015UTC_17.pdf"

In Windows this starts AcroRd32.exe with the "page=7" parameter and reads the specified .pdf file.  Works great, opens page #7.

Now I want to do this in an AutoIt script.   I've read the Run function description and had a lot of trials and errors - mostly errors.

This part works, and starts up Acrobat, but I can't figure out how to pass Acrobat the /A "page=7" open parameter or point it to my .pdf file.

Dim $AcrobatPath = "C:Program Files (x86)AdobeReader 11.0ReaderAcroRd32.exe /n"
 
Case $iMsg = $idM80
     Run ($AcrobatPath)

 

Any suggestions and assistance will be greatly appreciated.

Thanks!

Share this post


Link to post
Share on other sites



This should be close:

Run('"C:\Program Files (x86)\Adobe\Reader 11.0\Reader\AcroRd32.exe" /A page=7 "C:\Users\Mike-K6MKF\Desktop\K6TU Predictions\_K6MKF MAR 2015\UTC_17.pdf"')

Jos :)


Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

You are probably falling foul of spaces in a parameter, which you overcome using quotes.

You could have

$AcrobatPath = "C:\Program Files (x86)\Adobe\Reader 11.0\Reader\AcroRd32.exe"
$parameter = ' /A "page=7" "C:\Users\Mike-K6MKF\Desktop\K6TU Predictions\_K6MKF MAR 2015\UTC_17.pdf"'
Run($AcrobatPath & $parameter)

Note the leading space at the beginning of $parameter

Also the use of single and double quotes.

To enclose double quotes, you use single quotes or vice-a-versa.

You may also need to provide the working directory.

But, perhaps using ShellExecute would work better.


AutoIt.4.Life Clubrooms - Life is like a Donut (secret key)

Make sure brain is in gear before opening mouth!
Remember, what is not said, can be just as important as what is said.

Spoiler

What is the Secret Key? Life is like a Donut

If I put effort into communication, I expect you to read properly & fully, or just not comment.
Ignoring those who try to divert conversation with irrelevancies.
If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it.
I'm only big and bad, to those who have an over-active imagination.

I may have the Artistic Liesense ;) to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage)

userbar.png

Share this post


Link to post
Share on other sites

Ha, Jos beat me to it. :P


AutoIt.4.Life Clubrooms - Life is like a Donut (secret key)

Make sure brain is in gear before opening mouth!
Remember, what is not said, can be just as important as what is said.

Spoiler

What is the Secret Key? Life is like a Donut

If I put effort into communication, I expect you to read properly & fully, or just not comment.
Ignoring those who try to divert conversation with irrelevancies.
If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it.
I'm only big and bad, to those who have an over-active imagination.

I may have the Artistic Liesense ;) to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage)

userbar.png

Share this post


Link to post
Share on other sites

Not just close, but exactly correct, Jos!   Thank you very much!   Now I can keep working with my prototype until my next obstacle.

Share this post


Link to post
Share on other sites

My thanks to TheSaint for additional information about the Run command.  This will certainly come in handy as I continue to learn AutoIt!

Share this post


Link to post
Share on other sites

This statement works great:

Case $iMsg = $idM80
Run('"C:Program Files (x86)AdobeReader 11.0ReaderAcroRd32.exe" /A page=16 "C:PredictionsUTC_80.pdf"')
 
My next question is how do I substitute a $page variable for the value 16 in the page=16 parameter expression?
 
Thanks in advance for your suggestions!

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

You really should be asking these questions in General Help & Support.

There are two main methods, either do StringReplace on 16

Or using something like my earlier code.

$AcrobatPath = "C:\Program Files (x86)\Adobe\Reader 11.0\Reader\AcroRd32.exe"
$page = "8"
$parameter = ' /A "page=' & $page & '" "C:\Users\Mike-K6MKF\Desktop\K6TU Predictions\_K6MKF MAR 2015\UTC_17.pdf"'
Run($AcrobatPath & $parameter)
Edited by TheSaint

AutoIt.4.Life Clubrooms - Life is like a Donut (secret key)

Make sure brain is in gear before opening mouth!
Remember, what is not said, can be just as important as what is said.

Spoiler

What is the Secret Key? Life is like a Donut

If I put effort into communication, I expect you to read properly & fully, or just not comment.
Ignoring those who try to divert conversation with irrelevancies.
If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it.
I'm only big and bad, to those who have an over-active imagination.

I may have the Artistic Liesense ;) to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage)

userbar.png

Share this post


Link to post
Share on other sites

OK - I'll head on over there!  Thanks for your support!

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  
Followers 0