FROM : Sam Stigler
DATE : Fri Apr 06 07:40:47 2007
Thanks; that took care of it for me. I can't believe I'd forgotten
all about AppleScript! Here's the code I used (most of it from
Technical Note TN2084) for anyone who's looking at this in the archives:
-(IBAction)parseSafariURL:(id)sender
{
// the following is heavily based on the sample code found in
Technical Note TN2084, found at developer.apple.com .
NSAppleScript *urlGetter = [[NSAppleScript alloc] initWithSource:
@"\ntell application \"Safari\"\n\tget URL of document 1\nend tell
\n"];
NSDictionary *errorDict;
NSAppleEventDescriptor *returnDescriptor = NULL;
returnDescriptor = [urlGetter executeAndReturnError:&errorDict];
[urlGetter release];
if ((returnDescriptor != NULL) && (kAENullEvent != [returnDescriptor
descriptorType])) {
// good execution, with AppleScript descriptor type returned.
NSString *url = [returnDescriptor stringValue]; // this works as
expected.
}
}
Sam
On Apr 6, 2007, at 1:01 PM, Andrew Satori wrote:
> use an applescript to get the current url and return it to your
> app. If you need sample code, I'll post it in the morning.
>
> Andy
>
> On Apr 5, 2007, at 10:53 PM, Sam Stigler wrote:
>
>> Hi,
>>
>> I'm trying to program something using Amazon Web Services, and I
>> really need a user-friendly way to figure out which Amazon item
>> the user is talking about. It strikes me that the best way to do
>> this is probably to have them be browsing Amazon in Safari at the
>> same time they are in my program, and then click a button or
>> something in my program so it can register and parse the Amazon
>> URL that is currently being viewed in Safari. Does anyone know of
>> a way to do this? I considered using WebKit to build my own
>> special-purpose browser inside my application, but it seems like
>> too much just to get the URL.
>>
>>
>> Thanks,
>>
>> Sam Stigler
>> <email_removed>
>> _______________________________________________
>>
>> Cocoa-dev mailing list (<email_removed>)
>>
>> Do not post admin requests or moderator comments to the list.
>> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>>
>> Help/Unsubscribe/Update your Subscription:
>> http://lists.apple.com/mailman/options/cocoa-dev/<email_removed>
>>
>> This email sent to <email_removed>
DATE : Fri Apr 06 07:40:47 2007
Thanks; that took care of it for me. I can't believe I'd forgotten
all about AppleScript! Here's the code I used (most of it from
Technical Note TN2084) for anyone who's looking at this in the archives:
-(IBAction)parseSafariURL:(id)sender
{
// the following is heavily based on the sample code found in
Technical Note TN2084, found at developer.apple.com .
NSAppleScript *urlGetter = [[NSAppleScript alloc] initWithSource:
@"\ntell application \"Safari\"\n\tget URL of document 1\nend tell
\n"];
NSDictionary *errorDict;
NSAppleEventDescriptor *returnDescriptor = NULL;
returnDescriptor = [urlGetter executeAndReturnError:&errorDict];
[urlGetter release];
if ((returnDescriptor != NULL) && (kAENullEvent != [returnDescriptor
descriptorType])) {
// good execution, with AppleScript descriptor type returned.
NSString *url = [returnDescriptor stringValue]; // this works as
expected.
}
}
Sam
On Apr 6, 2007, at 1:01 PM, Andrew Satori wrote:
> use an applescript to get the current url and return it to your
> app. If you need sample code, I'll post it in the morning.
>
> Andy
>
> On Apr 5, 2007, at 10:53 PM, Sam Stigler wrote:
>
>> Hi,
>>
>> I'm trying to program something using Amazon Web Services, and I
>> really need a user-friendly way to figure out which Amazon item
>> the user is talking about. It strikes me that the best way to do
>> this is probably to have them be browsing Amazon in Safari at the
>> same time they are in my program, and then click a button or
>> something in my program so it can register and parse the Amazon
>> URL that is currently being viewed in Safari. Does anyone know of
>> a way to do this? I considered using WebKit to build my own
>> special-purpose browser inside my application, but it seems like
>> too much just to get the URL.
>>
>>
>> Thanks,
>>
>> Sam Stigler
>> <email_removed>
>> _______________________________________________
>>
>> Cocoa-dev mailing list (<email_removed>)
>>
>> Do not post admin requests or moderator comments to the list.
>> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>>
>> Help/Unsubscribe/Update your Subscription:
>> http://lists.apple.com/mailman/options/cocoa-dev/<email_removed>
>>
>> This email sent to <email_removed>
| Related mails | Author | Date |
|---|---|---|
| Sam Stigler | Apr 6, 04:53 | |
| Andrew Satori | Apr 6, 05:01 | |
| Sam Stigler | Apr 6, 07:40 |






Cocoa mail archive

