|
|
Applescript - Please help
|
|
|
|
Fresh-Faced Recruit
Join Date: Sep 2005
Status:
Offline
|
|
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
|
|
|
|
|
|
|
|
|
Senior User
Join Date: Oct 2000
Location: Midwest
Status:
Offline
|
|
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
|
|
|
|
|
|
|
|
|
Mac Elite
Join Date: Oct 1999
Location: San Jose, Ca
Status:
Offline
|
|
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.
|
|
|
|
|
|
|
|
|
Senior User
Join Date: Oct 2000
Location: Midwest
Status:
Offline
|
|
Thanks, larkost! 14 years of Applescript and never knew that Finder would do that.
D'oh!
Craig
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Forum Rules
|
|
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is Off
|
|
|
|
|
|
|
|
|
|
|
|