Jump to content

Launching a pdf file from a script


Recommended Posts

I've been trying to launch a manual from a script but can't seem to make it work. It's very basic stuff but I'm new to this and I don't have the time to battle with it anymore.

This works:

Func Doc()

Run("explorer.exe G:\Documentation\Help.pdf")

EndFunc

As well as this:

Func Doc()

RunWait("explorer.exe G:\Documentation\Help.pdf")

EndFunc

Of course I can't have it point to a specific letter, instead I want it to point to my scriptdir.

One of the things I've tried, that doesn't work:

Func Doc()

Run("explorer.exe @ScriptDir & "\Documentation\Help.pdf"")

EndFunc

Any ideas?

Link to post
Share on other sites

you could look for your acrord32.exe

than this is your code

run("path\acrord32.exe " & @scriptdir & "\Documentation\Help.pdf")

have fun

usually the path is

@programfilesdir & "\adobe\acrobat *.*\reader\

I want to use explorer to determine whick application to use for opening the pdf file, since I don't want to limit myself to Acrobat/Adobe Reader.

Func HB()

Run("explorer.exe " & @ScriptDir & "\Documentation\Help.pdf")

EndFunc

Works!

Thanks so much for the help. I had a feeling it was just a small correction that needed to be made.

Could I ask for help with one more detail?

Is there a way to maximize the window (in my case Acrobat) that is opened when the pdf file is launched?

Link to post
Share on other sites

I want to use explorer to determine whick application to use for opening the pdf file, since I don't want to limit myself to Acrobat/Adobe Reader.

Func HB()

Run("explorer.exe " & @ScriptDir & "\Documentation\Help.pdf")

EndFunc

Works!

Thanks so much for the help. I had a feeling it was just a small correction that needed to be made.

Could I ask for help with one more detail?

Is there a way to maximize the window (in my case Acrobat) that is opened when the pdf file is launched?

Try this:

$file=@ScriptDir & "\Documentation\Help.pdf"

$command="C:\Windows\System32\Rundll32.exe Url,FileProtocolHandler " & $file

Run($command)

Hope it helps

Jim

Link to post
Share on other sites

Yes, I've tried the @SW_Maximize flag, and now in the way you described (?).

Func HB()

Run("explorer.exe " & @ScriptDir & "\Documentation\Help.pdf", "", @SW_MAXIMIZE)

EndFunc

Is this correct? It doesn't report an error, but it doesn't maximize the window either.

Edited by ksv247
Link to post
Share on other sites

How about letting the operating system open the pdf file based on file association. Using the "Start /Max" through a console will open your documents in a maximized window. If you use "Start /Min" then Adobe will open in a smaller window and minimized to the taskbar.

$HelpFile = @ScriptDir & "\Documentation\help.pdf"

Run(@Comspec & " /C Start /Max " & $HelpFile,"", @SW_hide)

Link to post
Share on other sites

Yes, it worked like you said.

Func HB()

Run("C:\Program Files\Internet Explorer\iexplore.exe " & @ScriptDir & "\Documentation\Help.pdf", "", @SW_MAXIMIZE)

EndFunc

"...open the pdf file based on file association" - This was my intention using explorer, but your idea was better.

$HelpFile = @ScriptDir & "\Documentation\help.pdf"

Run(@Comspec & " /C Start /Max " & $HelpFile,"", @SW_hide)

...works as well, maximizing the window AND using the default program for pdf files, thanks to all of you for your help.

ksv

Link to post
Share on other sites

I have used this before:

$helpfile=@ScriptDir & "\Documentation\Help.pdf"
    run("RunDLL32.EXE url.dll,FileProtocolHandler "&$helpfile)

RunDLL32.exe will get the application associated with the extension and lauch it.

Steve

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
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...