Jump to content

Understanding The AutoIt Run Command Structure


Recommended Posts

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!

Link to comment
Share on other sites

  • Developers

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 :)

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

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.

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

Link to comment
Share on other sites

Ha, Jos beat me to it. :P

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

Link to comment
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!
Link to comment
Share on other sites

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

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

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