是否可以知道通过 AppleScript 事件收到的 GURL 调用的引荐来源网址?

发布于 2024-09-16 16:24:01 字数 680 浏览 5 评论 0原文

我有一个与我的 Cocoa 应用程序关联的协议处理程序。

[[NSAppleEventManager sharedAppleEventManager] 
    setEventHandler:self
    andSelector:@selector(getUrl:withReplyEvent:)
    forEventClass:kInternetEventClass andEventID:kAEGetURL];    

...

- (void)getUrl:(NSAppleEventDescriptor *)event withReplyEvent:(NSAppleEventDescriptor *)replyEvent
{
#ifdef DEBUG
    NSLog(@"%s: %@",__PRETTY_FUNCTION__,event);
#endif
    NSURL *url = [NSURL URLWithString:[[event paramDescriptorForKeyword:keyDirectObject] stringValue]];
...
}

谁是推荐人? (如果它从本地计算机调用,我认为它可能是未定义的,但如果我调用 来自网站的该协议...我想知道接收请求的域。

有可能吗?

是否有通过其他方式解决此任务的解决方案?

I have a protocol handler associated with my Cocoa application.

[[NSAppleEventManager sharedAppleEventManager] 
    setEventHandler:self
    andSelector:@selector(getUrl:withReplyEvent:)
    forEventClass:kInternetEventClass andEventID:kAEGetURL];    

...

- (void)getUrl:(NSAppleEventDescriptor *)event withReplyEvent:(NSAppleEventDescriptor *)replyEvent
{
#ifdef DEBUG
    NSLog(@"%s: %@",__PRETTY_FUNCTION__,event);
#endif
    NSURL *url = [NSURL URLWithString:[[event paramDescriptorForKeyword:keyDirectObject] stringValue]];
...
}

Who is referrer? (if it called from local machine I think it can be undefined, but if I call
this protocol from a Web site... I would like to know domain from which the request is received.

Is it possible at all?

Is there solution to solve this task by another way?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

梅倚清风 2024-09-23 16:24:02

尝试检查回复事件的目标。该事件将被发送回向您发送原始事件的任何应用程序,无论它位于何处。

如果您的意思是用户正在单击应用程序处理的链接,并且您想知道包含该链接的页面的 URL:则无法做到这一点。

Try inspecting the target of the reply event. That event will be sent back to whatever application sent you the original event, wherever it may be.

If you mean the user is clicking on a link that your application handles, and you want to know the URL of the page that contained the link: There's no way to do that.

柠北森屋 2024-09-23 16:24:01

从:
http://www.cocoabuilder.com/archive/cocoa/125741-finding-the-sender-of-an-appleevent-in-cocoa-app-on-10-2- 8-或-更大.html

NSAppleEventDescriptor *addrDesc = [event
attributeDescriptorForKeyword:keyAddressAttr];
NSData *psnData = [[addrDesc
coerceToDescriptorType:typeProcessSerialNumber] data];

if (psnData)
{
 ProcessSerialNumber psn = *(ProcessSerialNumber *) [psnData bytes];
 ...
}

From:
http://www.cocoabuilder.com/archive/cocoa/125741-finding-the-sender-of-an-appleevent-in-cocoa-app-on-10-2-8-or-greater.html

NSAppleEventDescriptor *addrDesc = [event
attributeDescriptorForKeyword:keyAddressAttr];
NSData *psnData = [[addrDesc
coerceToDescriptorType:typeProcessSerialNumber] data];

if (psnData)
{
 ProcessSerialNumber psn = *(ProcessSerialNumber *) [psnData bytes];
 ...
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文