• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Seeing which page Safari is currently browsing
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Seeing which page Safari is currently browsing


  • Subject: Re: Seeing which page Safari is currently browsing
  • From: Sam Stigler <email@hidden>
  • Date: Fri, 6 Apr 2007 15:40:47 +1000

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@hidden
_______________________________________________

Cocoa-dev mailing list (email@hidden)

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:
This email sent to email@hidden

_______________________________________________

Cocoa-dev mailing list (email@hidden)

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:
This email sent to email@hidden


References: 
 >Seeing which page Safari is currently browsing (From: Sam Stigler <email@hidden>)
 >Re: Seeing which page Safari is currently browsing (From: Andrew Satori <email@hidden>)

  • Prev by Date: Return code of process given ID
  • Next by Date: Re: NSView and array of moveable NSImages
  • Previous by thread: Re: Seeing which page Safari is currently browsing
  • Next by thread: Re: How to display errors/warnings at app startup? (Delaying the Opening of Files on Launch)
  • Index(es):
    • Date
    • Thread