Re: open command no longer being sent to our app
Re: open command no longer being sent to our app
- Subject: Re: open command no longer being sent to our app
- From: Steve Mills <email@hidden>
- Date: Wed, 07 Oct 2009 14:03:14 -0500
On Oct 7, 2009, at 13:21:07, Stockly, Ed wrote:
Try something like this and see if it helps:
Set fyl to posix path of fyl
tell application "MultiAd Creator Pro" to Open fyl
Or
Set fyl to fyl as text
tell application "MultiAd Creator Pro" to Open file fyl
Yes, converting the alias to text works (because we handle HFS style
paths, not posix paths yet). Here's the weird thing: If the only item
given to the open handler is an alias to a file, then our app receives
the event. But, if there's a folder in the list given to the open
handler, then I gather the alii in that folder and call the open
handler a 2nd time (recursively). It's these alii that cause the open
command to get intercepted by the OS instead of being sent directly to
the target app. Perhaps there's a better way to get the list of items
in a folder that will work across many versions of OS X, from 10.6
back? Here's the full script at this point.
on open fyls
repeat with fyl in fyls
try
tell application "System Events"
--Call ourself recursively with the items in this folder:
set fold to folder (get POSIX path of fyl)
set subFyls to every alias of fold
tell me to open subFyls
end tell
on error err
tell application "System Events"
set theFile to file (get POSIX path of fyl)
set canOpen to false
if visible of theFile then
set canOpen to true
end if
end tell
if canOpen then
tell application "MultiAd Creator Pro"
try
--set fyl to fyl as alias
open fyl with interaction and text overflow checking
try
--save document 1
on error err
display dialog err
end try
close document 1
on error err
display dialog err
end try
end tell
end if
end try
end repeat
end open
At this point, I'm using the outer try block as a way to see if each
item is a folder or file. If it fails the "set fold to folder..."
line, then it's a file. I don't know of a better way to check if an
item if a file or folder that will work across many versions of OS X.
Steve Mills
Drummer, Mac geek
http://sjmills5.home.mchsi.com/
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden