Jump to content

Run( )'s limitations


Recommended Posts

  • Administrators

I can only get Run( ) to open applications like calculator and notepad. I need to get Run( ) to open Adobe Acrobat, but it does not work. I'm using AutoItSetOption("WinTitleMatchMode",2), but Run('Adobe Acrobat') is not working.

Do you mean you want to run a .pdf file? Use ShellExecute() for that :whistle:

Link to comment
Share on other sites

  • Developers

I can only get Run( ) to open applications like calculator and notepad. I need to get Run( ) to open Adobe Acrobat, but it does not work. I'm using AutoItSetOption("WinTitleMatchMode",2), but Run('Adobe Acrobat') is not working.

You need to specify the exact programname to execute including the Path when its not in the searchpath.

eg:

Run(@ProgramFilesDir & "\Adobe\Reader 8.0\Reader\AcroRd32.exe")

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 need to specify the exact programname to execute including the Path when its not in the searchpath.

eg:

Run(@ProgramFilesDir & "\Adobe\Reader 8.0\Reader\AcroRd32.exe")
I don't understand macros, like the @PRogramFilesDir you used. Where can I read up on them. (I am an absolute beginner.)

Or perhaps you have a nice succinct explanation.

Link to comment
Share on other sites

  • Developers

I don't understand macros, like the @PRogramFilesDir you used. Where can I read up on them. (I am an absolute beginner.)

Or perhaps you have a nice succinct explanation.

The Helpfile is your friend for checking on these and all other keywords/functions/macros and UDF's

I would recommend loading SciTE4AutoIt3 (see my sig) and them open the script in SciTE.

All you need to do is put you cursor on the "word" you want to search the helpfile on and press F1 ...

:whistle:

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

Hi,

I'm a beginner to and have found the AutoIT.chm file included with AutoIT and excellent source for help.

BTW @ProgramFilesDir means "path to Program Files folder", useful in cases where its not always in the same location

I don't understand macros, like the @PRogramFilesDir you used. Where can I read up on them. (I am an absolute beginner.)

Or perhaps you have a nice succinct explanation.

Link to comment
Share on other sites

Or

Run("C:\Program Files\Adobe\Reader 8.0\Reader\AcroRd32.exe")

In Run("C:\Program Files\Adobe\Reader 8.0\Reader\AcroRd32.exe") the "C:\Program Files\Adobe\Reader 8.0\Reader\AcroRd32.exe" must be the name of a file, right? With the Run() function here are you mentioning both the program and the file?

If run is used to only open files how come it can open programs like notepad and not Adobe?

Link to comment
Share on other sites

Can the same construction be used to get to any other file. For instance, does @DocumentsFile or something like that take you to your document's folder. Or more specifically, for example, can something like @FreshmanDocumentsFile take you to your folder for the documents you used to store files as a freshman?

Here is where we need that qoute about a certain level of competency (or something like that)!

Did you find @FreshmanDocumentsFile in the help file? No, you didn't. Have you ever looked in the Documents and Settings folder in Explorer? There is a sub-folder for every user. @MyDocumentsDir contains the path to YOUR My Documents folder.

Ralph

Link to comment
Share on other sites

Can the same construction be used to get to any other file. For instance, does @DocumentsFile or something like that take you to your document's folder. Or more specifically, for example, can something like @FreshmanDocumentsFile take you to your folder for the documents you used to store files as a freshman?

A quick look at the AutoIt help file under Macros will give you the list. Or follow the OnLine help link in my sig to get the same information. Edited by GEOSoft

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Link to comment
Share on other sites

Here is where we need that qoute about a certain level of competency (or something like that)!

Did you find @FreshmanDocumentsFile in the help file? No, you didn't. Have you ever looked in the Documents and Settings folder in Explorer? There is a sub-folder for every user. @MyDocumentsDir contains the path to YOUR My Documents folder.

Ralph

Of course it was not in the help file. I was just thinking of constructing macros based of the way the @MyDocumentsDir macro looks. I was thinking perhaps such a process could resemble the construction of a user function or the defining of a variable. I guess this is not the case.

Link to comment
Share on other sites

I finally opened Adobe with this: Run("C:\Program Files\Adobe\Acrobat 6.0\Acrobat\Acrobat.exe")

This is nice, but what I really need to do is open and compress one file after another from a long list of files in a temp folder. I've already written the code to compress, save, and close a file, but I have no I idea how to extract file from the temp file one after the other to run the script I've already written.

Opening a file would have opened acrobat anyway.

Link to comment
Share on other sites

I finally opened Adobe with this: Run("C:\Program Files\Adobe\Acrobat 6.0\Acrobat\Acrobat.exe")

This is nice, but what I really need to do is open and compress one file after another from a long list of files in a temp folder. I've already written the code to compress, save, and close a file, but I have no I idea how to extract file from the temp file one after the other to run the script I've already written.

Opening a file would have opened acrobat anyway.

If you know The parameters for using Acrobat.exe to compress a file then take a look at ShellExecuteWait()

Write the file list to an array ($f_Array) and put it all in a loop.

For $I = 1 To Ubound($f_Array)-1
   ShellExecuteWait("Path to acrobat.exe", "parameters including $f_Array[$I]"
Next

You may have to look in the registry to see if there is a verb for the compress function. If there is then it's much simpler.

For $I = 1 To Ubound($F_Array)-1
   ShellExecuteWait($F_Array[$I],"","","Compress")
   FileCopy($F_Array[$I], "Old File Path & Name", 1)
Next

EDIT: Syntax Error

Edited by GEOSoft

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Link to comment
Share on other sites

Thank you very much for your fresh perspective.

I have some questions:

"Write the file list to an array ($f_Array) and put it all in a loop." -How do I do this? $f_Array[0]=file1, $f_Array[1]=file2...? It is a long list of 14000 files.

Where can I find the parameters for acrobat?

This just opens each file one at a time, right? But I don't understand how is involved.

For $I = 1 To Ubound($f_Array)-1
   ShellExecuteWait("Path to acrobat.exe", "parameters including $f_Array[$I]"
Next

"You may have to look in the registry to see if there is a verb for the compress function." - Where is this registry?

If I use the code below do I need to use the code above? This code seems to compress the files without opening a window.

For $I = 1 To Ubound($F_Array)-1
   ShellExecuteWait($F_Array[$I],"","","Compress")
   FileCopy($F_Array[$I], "Old File Path & Name", 1)
Next

Thanks again

Link to comment
Share on other sites

"You may have to look in the registry to see if there is a verb for the compress function."

There is no such a verb and also Acrobat actice x (DLL) and Adobe-JS don't support it on a easy way, because compression is normaly done direct from the PDF print driver.

With the freeware command line tool PDFTk. exe you can compress PDFs easy.

That's a well known and easy to handle command-line tool, so don't be afraid to downlod and use it.

I tested the compression and it gave me better results as Adobe Acrobat.

http://www.pdfhacks.com/pdftk/

To work with that tool, based on that what was tooled before, you may do following

DIM $pdft = C:\.......\PDFtk.exe ;full path to pdftk

then use something like this

Run(@ComSpec & " /c " &$pdftk&" "&$fileNameIN &" output " &$fileNameOut &" compress","",@SW_HIDE,$STDERR_CHILD + $STDOUT_CHILD)

Where $fileNameIn is the variable for the Input PDF; $fileNameOut that one for the output PDF. Both names can also be the same.

Good luck, Reinhard

Edited by ReFran
Link to comment
Share on other sites

"You may have to look in the registry to see if there is a verb for the compress function."

There is no such a verb and also Acrobat actice x (DLL) and Adobe-JS don't support it on a easy way, because compression is normaly done direct from the PDF print driver.

With the freeware command line tool PDFTk. exe you can compress PDFs easy.

That's a well known and easy to handle command-line tool, so don't be afraid to downlod and use it.

I tested the compression and it gave me better results as Adobe Acrobat.

http://www.pdfhacks.com/pdftk/

To work with that tool, based on that what was tooled before, you may do following

DIM $pdft = C:\.......\PDFtk.exe ;full path to pdftk

then use something like this

Run(@ComSpec & " /c " &$pdftk&" "&$fileNameIN &" output " &$fileNameOut &" compress","",@SW_HIDE,$STDERR_CHILD + $STDOUT_CHILD)

Where $fileNameIn is the variable for the Input PDF; $fileNameOut that one for the output PDF. Both names can also be the same.

Good luck, Reinhard

DIM $pdft = C:\.......\PDFtk.exe

Run(@ComSpec & " /c " &$pdftk

Either $pdft or $pdftk in both places

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

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