我正在开发使用AppleEvents的C应用程序。到目前为止,我正在尝试做一个简单的例子,发送激活到终端。这就是我所拥有的:
int main()
{
AppleEvent theEvent;
char* arg = "com.apple.Terminal";
AEAddressDesc addDesc;
OSErr err = AECreateDesc( typeApplicationBundleID, &arg, strlen( arg ), &addDesc );
printf("AECreateDesc error --> %dn", err);
if( noErr == err )
{
// my event creation
// create event:
err = AECreateAppleEvent( 'misc', 'actv', &addDesc, kAutoGenerateReturnID, kAnyTransactionID, &theEvent );
}
printf("AECreateAppleEvent error --> %dn", err);
if (noErr == err)
{
AESendMode aeSendMode = kAEAlwaysInteract | kAEWaitReply;
//err = AESend( &theEvent, NULL, aeSendMode, kAENormalPriority, kAEDefaultTimeout, NULL, NULL );
err = AESendMessage(&theEvent, NULL, aeSendMode, kAEDefaultTimeout);
}
printf("AESend error --> %dn", err);
return 0;
}
但当我运行程序时,它总是打印AESend错误-->-600,我看到这意味着进程没有找到
有人能告诉我这里出了什么问题吗?
注意:我不想使用AppleScript,我想使用这个,所以请不要推荐使用AppleScript
提前感谢并问候
您应该调用:
OSErr err = AECreateDesc( typeApplicationBundleID, arg, strlen( arg ), &addDesc );
没有CCD_ 1。