RE: Launching a local file in the default browser
Hello, Here's some help : > The following puts up a "compiler error"... > get "send open file" && tURL && "to Finder" > do it as AppleScript > put the result You are not quoting your arguments. Try this : put quote & tURL & quote into tURL put quote & "Finder" & quote into tAPP get "send open file" && tURL && "to" && tAPP do it as AppleScript put the result > Any offerings? Still much needed here! Here is an AppleScript droplet that tells you what the Creator and Filetype of the file dropped on it are. It is coded as a droplet, but it could be adapted such that the fileReference is passed a parameter. An *easy* task that will be left to the reader to accomplish. http://ufp.uqam.ca/pan/misc/ShowCreatorAndType.sit Hope this helps, Alain F __ Do you Yahoo!? Yahoo! SiteBuilder - Free, easy-to-use web site design software http://sitebuilder.yahoo.com ___ metacard mailing list [EMAIL PROTECTED] http://lists.runrev.com/mailman/listinfo/metacard
RE: Launching a local file in the default browser
Hugh, You do this applescript: tell application "Finder" open file end tell Works like a charm (but remember you need to have ":"-delimited paths). Ken Ray Sons of Thunder Software Email: [EMAIL PROTECTED] Web Site: http://www.sonsothunder.com/ -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of [EMAIL PROTECTED] Sent: Monday, August 18, 2003 2:32 PM To: [EMAIL PROTECTED] Subject: RE: Launching a local file in the default browser The Original: Ken wrote: > I tried it without the "file:///" in OS X as well as with other > variations with less than three slashes. All did nothing. Perhaps it's > the fact they are "/"-delimited paths that they require "file:///" ? As Brian points out, the third / is the first character of the Mac path... send "file://" & "/Alice/Desktop Folder/myGif.gif" to program "Finder" with "GURLGURL" should happily attempt to open the file in the default Browser. This is fine, so long as the Browser can display the filePath like images and simple text. But... What's the syntax to open ANY file with it's native application when you don't know the filetype-creator? It must be possible as the Finder does it when you double-click an icon on the desktop. I'm sure that sending the appropriate AppleScript to Finder would do the trick, as in... put "send open file"&&tURL&& "to Finder" into tScript do tScript as AppleScript put the result (okay, this puts "compiler error", but that's because I don't know AppleScript!) I suspect there will be syntax differences between MacOS and OSX (perhaps "file" vs "location") Any offerings? Still much needed here! /H ___ metacard mailing list [EMAIL PROTECTED] http://lists.runrev.com/mailman/listinfo/metacard
RE: Launching a local file in the default browser
The Original: Ken wrote: > I tried it without the "file:///" in OS X as well as with other > variations with less than three slashes. All did nothing. Perhaps it's > the fact they are "/"-delimited paths that they require "file:///" ? As Brian points out, the third / is the first character of the Mac path... send "file://" & "/Alice/Desktop Folder/myGif.gif" to program "Finder" with "GURLGURL" should happily attempt to open the file in the default Browser. This is fine, so long as the Browser can display the filePath like images and simple text. But... What's the syntax to open ANY file with it's native application when you don't know the filetype-creator? It must be possible as the Finder does it when you double-click an icon on the desktop. I'm sure that sending the appropriate AppleScript to Finder would do the trick, as in... put "send open file"&&tURL&& "to Finder" into tScript do tScript as AppleScript put the result (okay, this puts "compiler error", but that's because I don't know AppleScript!) I suspect there will be syntax differences between MacOS and OSX (perhaps "file" vs "location") Any offerings? Still much needed here! /H
Re: Launching a local file in the default browser
I tried it without the "file:///" in OS X as well as with other variations with less than three slashes. All did nothing. Perhaps it's the fact they are "/"-delimited paths that they require "file:///" ? I would suspect this is true. "file://" (with two colons) is really the proper protocol, as it corresponds to "http://";, "ftp://";, etc. Using "file://" is really just forming a proper URL- the oddity is that file paths also start with a slash, so you get the three slashes. But if you think of URLs as a protocol followed by a path, it starts to make sense- especially if you are accustomed to seeing "http://"; by now. FWIW Brian ___ metacard mailing list [EMAIL PROTECTED] http://lists.runrev.com/mailman/listinfo/metacard
RE: Launching a local file in the default browser
Hugh, I tried it without the "file:///" in OS X as well as with other variations with less than three slashes. All did nothing. Perhaps it's the fact they are "/"-delimited paths that they require "file:///" ? Ken Ray Sons of Thunder Software Email: [EMAIL PROTECTED] Web Site: http://www.sonsothunder.com/ -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of [EMAIL PROTECTED] Sent: Friday, August 15, 2003 4:50 PM To: [EMAIL PROTECTED] Subject: Re: Launching a local file in the default browser Ken suggests that this syntax works for Macs... but is the "file:///" actually necessary? I understood that works fine on both flavours. Not sure whether "/" has to be replaced by ":" as the delimiter, however. Anyone care to confirm these points for MacOS and MacOSX? I have a vested interest in the outcome! /H ___ metacard mailing list [EMAIL PROTECTED] http://lists.runrev.com/mailman/listinfo/metacard
Re: Launching a local file in the default browser
Ken suggests that this syntax works for Macs... but is the "file:///" actually necessary? I understood that works fine on both flavours. Not sure whether "/" has to be replaced by ":" as the delimiter, however. Anyone care to confirm these points for MacOS and MacOSX? I have a vested interest in the outcome! /H
RE: Launching a local file in the default browser
Ben, > If you don't care about the file type/creator, you may be > able to get away with nullifying those, and asking the Finder > to open the URL - but you'll still have to decide how many > slashes to use. Actually, it seems that it doesn't matter if you tell the Finder to open the URL; three slashes works for Safari, Opera, IE, Mozilla, OmniWeb and Camino (I didn't get a chance to test iCab). The approach I used (after stripping file type/creator was taking the path to the file, removing the first slash if there was one and then: send "file:///" & tPath to program "Finder" with "GURLGURL" Ken Ray Sons of Thunder Software Email: [EMAIL PROTECTED] Web Site: http://www.sonsothunder.com/ ___ metacard mailing list [EMAIL PROTECTED] http://lists.runrev.com/mailman/listinfo/metacard
Re: Launching a local file in the default browser
on 9/8/03 7:13 am, Richard Gaskin wrote > Yep, the same ol' question: how do I launch a local file in the default > browser on Mac OS X? > > And for future reference: Where is the definitive answer archived? Richard, Probably too late because I've just been catching up with a bunch of mailing list mail; but my answer to this is "it's a real pain". The standard way as others have noted is to use AppleScript to ask the Finder to open the URL. This works for "http://"; URLs, but for "file://" URLs it tends to start looking at type and creator, and sending them to that app instead. You may be able to get by setting the filetype to ""; I dabbled with this, adding a preference to my app to do this, but although it seemed to work in my first casual test on X, my first X user said it didn't help him - in any case my app really wants to create files assigned to BBEdit, but preview them in the browser, so I looked further. As others have noted, the standard way to ask a browser to look at a URL (local or remote) on MacOS has always been through the GURL ("openurl") AppleEvent. This was never mandated, nor has it been removed: it was only ever a convention, but it was widely observed. IE or Netscape (I think the latter) introduced it, and all other browsers implemented it - except !?£$& Safari, which of course is rapidly becoming the default browser on an awful lot of MacOS X desktops. This was the first bug I reported to Safari. Safari instead introduces its own suite of AppleEvents - typically arrogant Apple behaviour. As if this wasn't bad enough, there is considerable disagreement about the exact format of a file URL, because MacOS X paths start with a "/". So should it be "file:/Users/fred/blah.html" Or "file:///Users/fred/blah.html" or "file://Users/fred/blah.html" The answer is it depends who you ask. MetaTalk/Transcript like the first form. Safari (v51) and IE 5.2 want the second. Opera and iCab want the third. So... essentially you need a routine which knows which browser it's going to use. For my app I've currently given the MacOS X users a special preference in which they choose the browser, overriding their system-wide preference. I haven't tried retrieving that system-wide preference as some have indicated - it might work. So my URL launching routine (for X) knows the browser to talk to; and depending on the browser, adjusts the number of slashes following "file:"; and then depending on the browser, either uses the openurl event to get that file viewed, or a more complicated script if the app is Safari. Of course, all of this is fragile; if the browser isn't one of the four I know about, I make a guess about how many slashes, and trust it implements the openurl event. And if you've chosen to name your copy of iCab "Safari", the results will be disappointing. If you don't care about the file type/creator, you may be able to get away with nullifying those, and asking the Finder to open the URL - but you'll still have to decide how many slashes to use. Hope this helps (?!?) Ben Rubinstein | Email: [EMAIL PROTECTED] Cognitive Applications Ltd | Phone: +44 (0)1273-821600 http://www.cogapp.com| Fax : +44 (0)1273-728866 ___ metacard mailing list [EMAIL PROTECTED] http://lists.runrev.com/mailman/listinfo/metacard
Re: Launching a local file in the default browser
Brian Yennie wrote: > If there's not a better way, you could work around this by creating a > dummy HTML file that just redirects the browser to the correct file. > That'll get you in the right app, *then* open the file. But how to get the default browser so I can obtain its creator code? -- Richard Gaskin Fourth World Media Corporation Developer of WebMerge: Publish any database on any Web site ___ [EMAIL PROTECTED] http://www.FourthWorld.com Tel: 323-225-3717 AIM: FourthWorldInc ___ metacard mailing list [EMAIL PROTECTED] http://lists.runrev.com/mailman/listinfo/metacard
Re: Launching a local file in the default browser
Ken Ray wrote: > Richard, you posted this to the MC list last year under the header : > > Found it: You have to explicitely tell the Finder, like this: > > put "tell application ""e&"Finder""e&cr&"open ""e& \ > tFilePath "e&cr&"end tell" into s > do s as AppleScript > > See: http://lists.runrev.com/pipermail/metacard/2002-January/000569.html > > But I just checked it and it doesn't work for me. Same here: it launches the local file, but in the application that matches the file's creator code and not the default browser. :( > I'll keep looking... Thanks. Hopefully one of us will solve this once and for all... -- Richard Gaskin Fourth World Media Corporation Developer of WebMerge: Publish any database on any Web site ___ [EMAIL PROTECTED] http://www.FourthWorld.com Tel: 323-225-3717 AIM: FourthWorldInc ___ metacard mailing list [EMAIL PROTECTED] http://lists.runrev.com/mailman/listinfo/metacard
Re: Launching a local file in the default browser
Still works... I did miss the "local" though and skipped my eyes to the "browser". In any case, try this form: tell application "Finder" open location "file:///Users/yennie/Desktop/test.html" end tell The trick seems to be adding the browser-style protocol to the front for local files: "file://" You should have 3 slashes total- the third is part of the file path. HTH Brian Uh, Brian... he mentioned a "local file" not a web site. Will this still work? Ken Ray Sons of Thunder Software Email: [EMAIL PROTECTED] Web Site: http://www.sonsothunder.com/ -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Brian Yennie Sent: Saturday, August 09, 2003 1:49 AM To: [EMAIL PROTECTED] Subject: Re: Launching a local file in the default browser tell application "Finder" open location "http://www.apple.com"; end tell ... "do" as AppleScript of course Yep, the same ol' question: how do I launch a local file in the default browser on Mac OS X? And for future reference: Where is the definitive answer archived? ___ metacard mailing list [EMAIL PROTECTED] http://lists.runrev.com/mailman/listinfo/metac> ard ___ metacard mailing list [EMAIL PROTECTED] http://lists.runrev.com/mailman/listinfo/metacard ___ metacard mailing list [EMAIL PROTECTED] http://lists.runrev.com/mailman/listinfo/metacard
Re: Launching a local file in the default browser
sims wrote: > If I use: > > set this_item to ¬ > alias "Macintosh HD:Users:jimsims:Pictures:iPhoto > Library:2002:10:29:taufeg.jpg" > tell application "Internet Explorer" > open this_item > end tell > > A file which I created with ColorIt or PhotoShop will launch with the > indicated browser. > I suspect that the alias has some magical powers. That will open fine in IE, but what if the user's default browser is Safari? -- Richard Gaskin Fourth World Media Corporation Developer of WebMerge: Publish any database on any Web site ___ [EMAIL PROTECTED] http://www.FourthWorld.com Tel: 323-225-3717 AIM: FourthWorldInc ___ metacard mailing list [EMAIL PROTECTED] http://lists.runrev.com/mailman/listinfo/metacard
Re: Launching a local file in the default browser #3
At 9:45 +0200 8/9/03, sims wrote: If I use: set this_item to ¬ alias "Macintosh HD:Users:jimsims:Pictures:iPhoto Library:2002:10:29:taufeg.jpg" tell application "Internet Explorer" open this_item end tell A file which I created with ColorIt or PhotoShop will launch with the indicated browser. I suspect that the alias has some magical powers. Is that what you are looking for? NOTE - I never actually create an alias nor does applescript create an alias (as far as I can tell) but it uses it as some sort of reference to enable the launch. atb sims -- --- http://EZPZapps.com [EMAIL PROTECTED] Software - Internet Development - Consulting ___ metacard mailing list [EMAIL PROTECTED] http://lists.runrev.com/mailman/listinfo/metacard
Re: Launching a local file in the default browser
Er... I guess I should probably get some sleep: my solution has this problem also for files that don't normally open in a browser. If there's not a better way, you could work around this by creating a dummy HTML file that just redirects the browser to the correct file. That'll get you in the right app, *then* open the file. There must be a better way buried somewhere in AppleScript... Brian Same here: it launches the local file, but in the application that matches the file's creator code and not the default browser. :( ___ metacard mailing list [EMAIL PROTECTED] http://lists.runrev.com/mailman/listinfo/metacard
Re: Launching a local file in the default browser #3
FWIW, there's also this nugget: ~/Library/Preferences/com.apple.internetconfig.plist You can also dig around in: ~/Library/Preferences/LaunchServices.plist It seems that you can use these to find the actual applications assigned to various file formats. Brian ___ metacard mailing list [EMAIL PROTECTED] http://lists.runrev.com/mailman/listinfo/metacard
RE: Launching a local file in the default browser
Richard, you posted this to the MC list last year under the header : Found it: You have to explicitely tell the Finder, like this: put "tell application ""e&"Finder""e&cr&"open ""e& \ tFilePath "e&cr&"end tell" into s do s as AppleScript See: http://lists.runrev.com/pipermail/metacard/2002-January/000569.html But I just checked it and it doesn't work for me. I'll keep looking... Ken Ray Sons of Thunder Software Email: [EMAIL PROTECTED] Web Site: http://www.sonsothunder.com/ > -Original Message- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On Behalf Of Richard Gaskin > Sent: Saturday, August 09, 2003 1:14 AM > To: MetaCard List > Subject: Launching a local file in the default browser > > > Yep, the same ol' question: how do I launch a local file in > the default browser on Mac OS X? > > And for future reference: Where is the definitive answer archived? > > TIA - > > -- > Richard Gaskin > Fourth World Media Corporation > Developer of WebMerge: Publish any database on any Web site > ___ > [EMAIL PROTECTED] http://www.FourthWorld.com > Tel: 323-225-3717 AIM: FourthWorldInc > > ___ > metacard mailing list > [EMAIL PROTECTED] > http://lists.runrev.com/mailman/listinfo/metac> ard > ___ metacard mailing list [EMAIL PROTECTED] http://lists.runrev.com/mailman/listinfo/metacard
Re: Launching a local file in the default browser
On 8/9/03 9:04 AM, "Richard Gaskin" <[EMAIL PROTECTED]> wrote: >> If there's not a better way, you could work around this by creating a >> dummy HTML file that just redirects the browser to the correct file. >> That'll get you in the right app, *then* open the file. > > But how to get the default browser so I can obtain its creator code? I'm not sure how to extract the above, but I'm pretty sure that any HTML file without specific creator/type info will automagically open in the default browser -- if this is your concern you shouldn't need to worry about it working. Regards, Scott Rossi Creative Director Tactile Media, Multimedia & Design - E: [EMAIL PROTECTED] W: http://www.tactilemedia.com ___ metacard mailing list [EMAIL PROTECTED] http://lists.runrev.com/mailman/listinfo/metacard
Re: Launching a local file in the default browser #3
Brian Yennie wrote: > FWIW, there's also this nugget: > > ~/Library/Preferences/com.apple.internetconfig.plist > > You can also dig around in: > > ~/Library/Preferences/LaunchServices.plist > > It seems that you can use these to find the actual applications > assigned to various file formats. Do those files have the same name in all localized versions of the OS? -- Richard Gaskin Fourth World Media Corporation Developer of WebMerge: Publish any database on any Web site ___ [EMAIL PROTECTED] http://www.FourthWorld.com Tel: 323-225-3717 AIM: FourthWorldInc ___ metacard mailing list [EMAIL PROTECTED] http://lists.runrev.com/mailman/listinfo/metacard
Re: Launching a local file in the default browser
Yep, the same ol' question: how do I launch a local file in the default browser on Mac OS X? And for future reference: Where is the definitive answer archived? Richard Gaskin If I use: set this_item to ¬ alias "Macintosh HD:Users:jimsims:Pictures:iPhoto Library:2002:10:29:taufeg.jpg" tell application "Internet Explorer" open this_item end tell A file which I created with ColorIt or PhotoShop will launch with the indicated browser. I suspect that the alias has some magical powers. Is that what you are looking for? atb sims -- --- http://EZPZapps.com [EMAIL PROTECTED] Software - Internet Development - Consulting ___ metacard mailing list [EMAIL PROTECTED] http://lists.runrev.com/mailman/listinfo/metacard
Re: Launching a local file in the default browser #2
At 9:45 +0200 8/9/03, sims wrote: If I use: set this_item to ¬ alias "Macintosh HD:Users:jimsims:Pictures:iPhoto Library:2002:10:29:taufeg.jpg" tell application "Internet Explorer" open this_item end tell A file which I created with ColorIt or PhotoShop will launch with the indicated browser. I suspect that the alias has some magical powers. Is that what you are looking for? I send that from a hidden Rev fld but have also done so with a Rev custom property. atb sims -- --- http://EZPZapps.com [EMAIL PROTECTED] Software - Internet Development - Consulting ___ metacard mailing list [EMAIL PROTECTED] http://lists.runrev.com/mailman/listinfo/metacard
RE: Launching a local file in the default browser
OK, Richard, I got it... you need to shell() to the "cp" to copy the file to a temporary filename; doing so will strip the type/creator and then you can launch it with "open" via appleScript (after converting the POSIX path to a normal mac path, of course): on launchit pPath put pPath into tDestPath set the itemDel to "/" put "temp.html" into last item of tDestPath get shell("cp" && pPath && tDestPath) put "tell application" && q("Finder") into s put cr & "set f to" && q(tDestPath) && " as POSIX file" after s put cr & "set p to f as text" after s put cr & "open file p" & cr & "end tell" after s do s as AppleScript end launchIt function q pWhat return quote & pWhat & quote end q This should work... Ken Ray Sons of Thunder Software Email: [EMAIL PROTECTED] Web Site: http://www.sonsothunder.com/ > -Original Message----- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On Behalf Of Richard Gaskin > Sent: Saturday, August 09, 2003 2:12 AM > To: [EMAIL PROTECTED] > Subject: Re: Launching a local file in the default browser > > > Ken Ray wrote: > > > Richard, you posted this to the MC list last year under the header : > > > > Found it: You have to explicitely tell the Finder, like this: > > > > put "tell application ""e&"Finder""e&cr&"open ""e& \ > > tFilePath "e&cr&"end tell" into s do s as AppleScript > > > > See: > > http://lists.runrev.com/pipermail/metacard/2002-January/000569.html > > > > But I just checked it and it doesn't work for me. > > Same here: it launches the local file, but in the > application that matches the file's creator code and not the > default browser. :( > > > I'll keep looking... > > Thanks. Hopefully one of us will solve this once and for all... > > -- > Richard Gaskin > Fourth World Media Corporation > Developer of WebMerge: Publish any database on any Web site > ___ > [EMAIL PROTECTED] http://www.FourthWorld.com > Tel: 323-225-3717 AIM: FourthWorldInc > > ___ > metacard mailing list > [EMAIL PROTECTED] > http://lists.runrev.com/mailman/listinfo/metac> ard > ___ metacard mailing list [EMAIL PROTECTED] http://lists.runrev.com/mailman/listinfo/metacard
RE: Launching a local file in the default browser
Uh, Brian... he mentioned a "local file" not a web site. Will this still work? Ken Ray Sons of Thunder Software Email: [EMAIL PROTECTED] Web Site: http://www.sonsothunder.com/ > -Original Message- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On Behalf Of Brian Yennie > Sent: Saturday, August 09, 2003 1:49 AM > To: [EMAIL PROTECTED] > Subject: Re: Launching a local file in the default browser > > > tell application "Finder" > open location "http://www.apple.com"; > end tell > > ... "do" as AppleScript of course > > > Yep, the same ol' question: how do I launch a local file in the > > default > > browser on Mac OS X? > > > > And for future reference: Where is the definitive answer archived? > > ___ > metacard mailing list > [EMAIL PROTECTED] > http://lists.runrev.com/mailman/listinfo/metac> ard > ___ metacard mailing list [EMAIL PROTECTED] http://lists.runrev.com/mailman/listinfo/metacard
Re: Launching a local file in the default browser
tell application "Finder" open location "http://www.apple.com"; end tell ... "do" as AppleScript of course Yep, the same ol' question: how do I launch a local file in the default browser on Mac OS X? And for future reference: Where is the definitive answer archived? ___ metacard mailing list [EMAIL PROTECTED] http://lists.runrev.com/mailman/listinfo/metacard