Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > Applescript - Please help

Applescript - Please help
Thread Tools
bingopie
Fresh-Faced Recruit
Join Date: Sep 2005
Status: Offline
Reply With Quote
Sep 7, 2005, 05:21 PM
 
Got the following applescript from another board and am trying to open a pdf file from a CD Rom tirggered from a button in Flahs. I have got the button in flash to initiate the script but am having a hard time getting the script to work.

This is the script:

tell application "Finder"
activate
select file "your-file.pdf" of disk "Your Disk"
open selection
end tell

The problem I am having is I get a syntax error "Expected end of line, etc. but found ". And it highlights the " at the begining of "Your Disk".

Then when I remove the quotes it tells me that the disk is not defined.

Does anybody have any idea how to mak this work, I think I am about to loose my mind.

Thanks,

Bingo
     
suthercd
Senior User
Join Date: Oct 2000
Location: Midwest
Status: Offline
Reply With Quote
Sep 7, 2005, 08:33 PM
 
The Finder cannot open the pdf, Preview is used to view pdfs by default but is not scriptable. Safari can open pdfs and can be scripted. A quick script:
--
set selectedFile to choose file

tell application "Safari"
open selectedFile
end tell
--

HTH
Craig
     
larkost
Mac Elite
Join Date: Oct 1999
Location: San Jose, Ca
Status: Offline
Reply With Quote
Sep 7, 2005, 09:26 PM
 
If you are absolutely sure that you know the disk name that this is going to be on (*hint* I am telling you this is a bad idea *hint*) you can use this one-line script:
Code:
tell application "Finder" to open file "path:to:file" of the disk named "Mac HD"
This will open it in whatever app the user has selected for that file type.


Oh... and it does not matter if Preview is scriptable or not... it will respond to the open command, like every other application that takes files. And in this case we are letting the Finder send that particular AppleEvent.
     
suthercd
Senior User
Join Date: Oct 2000
Location: Midwest
Status: Offline
Reply With Quote
Sep 8, 2005, 07:49 AM
 
Thanks, larkost! 14 years of Applescript and never knew that Finder would do that.

D'oh!
Craig
     
   
 
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Top
Privacy Policy
All times are GMT -4. The time now is 05:23 PM.
All contents of these forums © 1995-2017 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.8 © 2000-2017, Jelsoft Enterprises Ltd.,