Re: Communicating With Browser
Re: Communicating With Browser
- Subject: Re: Communicating With Browser
- From: Zack Morris <email@hidden>
- Date: Tue, 9 Nov 2004 20:09:37 -0700
On Nov 9, 2004, at 4:45 AM, Zack Morris wrote:
Anyway, the only errata with these routines is for some reason,
MakeOpenURLEvent() doesn't seem to work when I use
GetSenderAddressDesc(), and I don't know why. I was trying to get the
source of the apple event that came to me from Safari, and it didn't
work. I think it has something to do with the typeSessionID enum,
which was deprecated in Carbon.
Well, it appears that you can't get the source of an apple event in
carbon, or OS X. That's kind of a deal breaker for me, I dunno, I just
don't think that applescript is very useable in the real world. It's
pretty (like HyperTalk), but under the hood it is just really hard to
use. I tend to do a lot of trolling though :) I tried this code:
// return the sender of the apple event in desc. Remember to throw the
description away with AEDisposeDesc()
OSErr GetSenderAddressDesc( const AppleEvent *inAppleEvent,
AEAddressDesc *desc )
{
DescType theType;
char url[2048];
Size theSize;
OSErr err = AEGetAttributePtr( inAppleEvent, keyAddressAttr,
typeApplicationURL, &theType, url, 2048, &theSize );
if( err ) return( err );
// url should now be something like eppc://127.0.0.1/Safari
err = AECreateDesc( typeApplicationURL, url, theSize, desc );
return( err );
}
But I get a -1700 error (errAECoercionFail). I'm using
typeApplicationURL because typeSessionID and typeTargetID are
deprecated in Carbon. Luckily I don't really need to know the source
of an apple event for my app, because I can just use the default
browser. This will annoy people who are running FireFox but have
Safari set as their default browser though. I am thinking that it
might make more sense to loop over the running process list and send
out "pings" to the apps with a secret key and wait for a response of
some sort, and match the app to the response. Seems like an infinite
amount of work though, but maybe it would be useful. Does anyone know
how to ask for a response from an app with applescript? Or how to get
the name of the app that sent an apple event?
Also, when I add that interpreter code, I am a bit concerned about
using the app's name (Safari) instead of a unique identifier ('sfri' or
process serial num), in the off chance that someone renamed an app.
Maybe I worry too much. Hmmm, I just got an idea that I can use
javascript to put the name of the app into the url event that is sent
to my app, and then I can reply to that app! Well, this thread is
getting rapidly off topic, so I'll end with that. Thanx,
------------------------------------------------------------------------
Zack Morris Z Sculpt Entertainment This Space
email@hidden http://www.zsculpt.com For Rent
------------------------------------------------------------------------
If the doors of perception were cleansed, everything would appear to man
as it is, infinite. -William Blake, The Marriage of Heaven and Hell
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Macnetworkprog mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden