AppleEvent:如何调试`eventDidFail`?

发布于 2024-12-03 04:24:54 字数 2046 浏览 1 评论 0原文

我从控制台中的 SIMBL 收到此错误:

05.09.11 17:00:09,165 SIMBL Agent: eventDidFail:'tvea' error:Error Domain=NSOSStatusErrorDomain Code=-1708 "The operation couldn’t be completed. (OSStatus error -1708.)" (the AppleEvent was not handled by any handler ) UserInfo=0x400e485c0 {ErrorNumber=-1708} userInfo:{
    ErrorNumber = "-1708";
}

我正在尝试调试此错误;但由于我还没有真正使用 AppleEvent 那么多,所以我不太确定如何解释它。

我认为SIMBL Agent中的相关代码是这样的:

AEEventID eventID = 'load';

// Find the process to target
pid_t pid = [[appInfo objectForKey:@"NSApplicationProcessIdentifier"] intValue];
SBApplication* app = [SBApplication applicationWithProcessIdentifier:pid];
[app setDelegate:self];
if (!app) {
    SIMBLLogNotice(@"Can't find app with pid %d", pid);
    return;
}

// Force AppleScript to initialize in the app, by getting the dictionary
// When initializing, you need to wait for the event reply, otherwise the
// event might get dropped on the floor. This is only seems to happen in 10.5
// but it shouldn't harm anything.
[app setSendMode:kAEWaitReply | kAENeverInteract | kAEDontRecord];
id initReply = [app sendEvent:kASAppleScriptSuite id:kGetAEUT parameters:0];

// the reply here is of some unknown type - it is not an Objective-C object
// as near as I can tell because trying to print it using "%@" or getting its
// class both cause the application to segfault. The pointer value always seems
// to be 0x10000 which is a bit fishy. It does not seem to be an AEDesc struct
// either.
// since we are waiting for a reply, it seems like this object might need to
// be released - but i don't know what it is or how to release it.
// NSLog(@"initReply: %p '%64.64s'", initReply, (char*)initReply);

// Inject!
[app setSendMode:kAENoReply | kAENeverInteract | kAEDontRecord];
id injectReply = [app sendEvent:'SIMe' id:eventID parameters:0];
if (injectReply != nil) {
    SIMBLLogNotice(@"unexpected injectReply: %@", injectReply);
}

I am getting this error from SIMBL in the console:

05.09.11 17:00:09,165 SIMBL Agent: eventDidFail:'tvea' error:Error Domain=NSOSStatusErrorDomain Code=-1708 "The operation couldn’t be completed. (OSStatus error -1708.)" (the AppleEvent was not handled by any handler ) UserInfo=0x400e485c0 {ErrorNumber=-1708} userInfo:{
    ErrorNumber = "-1708";
}

I am trying to debug this; but as I haven't really worked with AppleEvent that much yet, I'm not really sure how to interpret that.

I think the related code in the SIMBL Agent is this:

AEEventID eventID = 'load';

// Find the process to target
pid_t pid = [[appInfo objectForKey:@"NSApplicationProcessIdentifier"] intValue];
SBApplication* app = [SBApplication applicationWithProcessIdentifier:pid];
[app setDelegate:self];
if (!app) {
    SIMBLLogNotice(@"Can't find app with pid %d", pid);
    return;
}

// Force AppleScript to initialize in the app, by getting the dictionary
// When initializing, you need to wait for the event reply, otherwise the
// event might get dropped on the floor. This is only seems to happen in 10.5
// but it shouldn't harm anything.
[app setSendMode:kAEWaitReply | kAENeverInteract | kAEDontRecord];
id initReply = [app sendEvent:kASAppleScriptSuite id:kGetAEUT parameters:0];

// the reply here is of some unknown type - it is not an Objective-C object
// as near as I can tell because trying to print it using "%@" or getting its
// class both cause the application to segfault. The pointer value always seems
// to be 0x10000 which is a bit fishy. It does not seem to be an AEDesc struct
// either.
// since we are waiting for a reply, it seems like this object might need to
// be released - but i don't know what it is or how to release it.
// NSLog(@"initReply: %p '%64.64s'", initReply, (char*)initReply);

// Inject!
[app setSendMode:kAENoReply | kAENeverInteract | kAEDontRecord];
id injectReply = [app sendEvent:'SIMe' id:eventID parameters:0];
if (injectReply != nil) {
    SIMBLLogNotice(@"unexpected injectReply: %@", injectReply);
}

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

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

发布评论

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

评论(1

何止钟意 2024-12-10 04:24:54

eventDidFail 消息也来自 SIMBL 代理本身。是这段代码:

- (void) eventDidFail:(const AppleEvent*)event withError:(NSError*)error
{
    NSDictionary* userInfo = [error userInfo];
    NSNumber* errorNumber = [userInfo objectForKey:@"ErrorNumber"];

    // this error seems more common on Leopard
    if (errorNumber && [errorNumber intValue] == errAEEventNotHandled) {
        SIMBLLogDebug(@"eventDidFail:'%4.4s' error:%@ userInfo:%@", (char*)&(event->descriptorType), error, [error userInfo]);
    }
    else {
        SIMBLLogNotice(@"eventDidFail:'%4.4s' error:%@ userInfo:%@", (char*)&(event->descriptorType), error, [error userInfo]);
    }
}

如果我注释掉这段代码,错误就会消失:

[app setSendMode:kAEWaitReply | kAENeverInteract | kAEDontRecord];
id initReply = [app sendEvent:kASAppleScriptSuite id:kGetAEUT parameters:0];

The eventDidFail message also comes from the SIMBL Agent itself. It is this code:

- (void) eventDidFail:(const AppleEvent*)event withError:(NSError*)error
{
    NSDictionary* userInfo = [error userInfo];
    NSNumber* errorNumber = [userInfo objectForKey:@"ErrorNumber"];

    // this error seems more common on Leopard
    if (errorNumber && [errorNumber intValue] == errAEEventNotHandled) {
        SIMBLLogDebug(@"eventDidFail:'%4.4s' error:%@ userInfo:%@", (char*)&(event->descriptorType), error, [error userInfo]);
    }
    else {
        SIMBLLogNotice(@"eventDidFail:'%4.4s' error:%@ userInfo:%@", (char*)&(event->descriptorType), error, [error userInfo]);
    }
}

And the error disappears if I comment out this code:

[app setSendMode:kAEWaitReply | kAENeverInteract | kAEDontRecord];
id initReply = [app sendEvent:kASAppleScriptSuite id:kGetAEUT parameters:0];
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文