Sign in to follow this  
Followers 0
Adson

Newbie question: How to run a pdf file?

8 posts in this topic

#1 ·  Posted (edited)

Hello, I try to write my first scripts with autoIt and wonder what is the best way to open a pdf file.

I used:

#include <Process.au3>

$rc = _RunDos("start bestellformular.pdf")

and this works but I'm not shure if this is the right way and that this will work on every Win 98 to Win Vista PC.

By searching in the forum I also found the shellexecute function. Unfortunately this does not work. It seems that this function is not included in my version of autoIt.

What is the best method to open a pdf file?

Thanks in advance for your help.

A.

Edited by Adson

Share this post


Link to post
Share on other sites



ShellExecute requires one of the latest betas/RCs. Get them here.

ShellExecute(@MyDocumentsDir & "\AP192_UG_EN.pdf")oÝ÷ Øò¢ìÛh²Ø­*.­Ë«­éí½êìí¯+(ëax%G­+ºÚ"µÍÌÍÜXYH  ÌÎNÉ][ÝÉÌÎNÈ    [ÈÙÜ[Q[Ñ    [È ÌÎNÉÌLÐYØIÌLÐXÜØ]
Ë  ÌLÔXYÌLÐXÜÔÌ^I][ÝÈ ÌÎNÂÌÍÜH  ÌÎNÉ][ÝÉÌÎNÈ    [È^QØÝ[Y[Ñ  [È ÌÎNÉÌLÐTNLÕQ×ÑS][ÝÉÌÎNÂ[   ÌÍÜXY    [È ÌÍÜ

Share this post


Link to post
Share on other sites

or use a ShellExecute UDF

_ShellExecute('C:\document.pdf')

Func _ShellExecute($filename, $parameters = '', $workingdir = '', $verb = 'open', $showflag = @SW_SHOWNORMAL)
    $aRet = DllCall("shell32.dll", "long", "ShellExecute", _
            "hwnd", 0, _
            "string", $verb, _
            "string", $filename, _
            "string", $parameters, _
            "string", $workingdir, _
            "int", $showflag)
    Return SetError(@error, 0, '')
EndFunc

:P

Share this post


Link to post
Share on other sites

Helge, thanks for your reply. Unfortunately I do not know which version of acrobat reader is installed on the machines where the autoIt.exe should run. The only thing I can do ist to run the pdf file so that it starts with the associated application (acrobat reader).

Since this seems to work with the _RunDos function, I will try it with

CODE
Run("mypdf.pdf")

Do you know if the shellexecute function has advantages in comparision with the run function?

A.

Share this post


Link to post
Share on other sites

...I do not know which version of acrobat reader is installed...

You won't even know if the user has an Adobe product for the PDF reader: http://www.foxitsoftware.com/pdf/rd_intro.php

Sorry, I cannot comment on your RUNDOS vs. ShellExecute question.


[size="1"][font="Arial"].[u].[/u][/font][/size]

Share this post


Link to post
Share on other sites

Use ShellExecute and make sure you are using the latest beta. ShellExecute is basically the same as right clicking a pdf in Explorer and clicking Open, or Edit or Print. ShellExecute allows you to specify a verb that determines what action you want to perform.

I would suggest not using Run or RunDOS.


“Give a man a script; you have helped him for today. Teach a man to script; and you will not have to hear him whine for help.”AutoIt4UE - Custom AutoIt toolbar and wordfile for UltraEdit/UEStudio users.AutoIt Graphical Debugger - A graphical debugger for AutoIt.SimMetrics COM Wrapper - Calculate string similarity.

Share this post


Link to post
Share on other sites

Thank you very much for your help :P

I will use ShellExecute as suggested. Does the current beta version include a description how to use ShellExecute?

A.

Share this post


Link to post
Share on other sites

Thank you very much for your help :P

I will use ShellExecute as suggested. Does the current beta version include a description how to use ShellExecute?

A.

Of course. You can also Google ShellExecute for more info. The AutoIt function is a wrapper for the API of the same name.


“Give a man a script; you have helped him for today. Teach a man to script; and you will not have to hear him whine for help.”AutoIt4UE - Custom AutoIt toolbar and wordfile for UltraEdit/UEStudio users.AutoIt Graphical Debugger - A graphical debugger for AutoIt.SimMetrics COM Wrapper - Calculate string similarity.

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