我正在尝试开始使用AppleEvents。我有一个简单的注册和处理日志:
static OSErr HandleOpenApplication(const AppleEvent* event, AppleEvent* ev, SRefCon sr)
{
LOG_HIGH("@@@@@@@@ Got Apple Event @@@@@@@");
return 0;
}
static OSErr InstallAppleEventHandlers()
{
OSErr err = 0;
err = AEInstallEventHandler(typeWildCard, typeWildCard,
NewAEEventHandlerUPP(HandleOpenApplication), 0, false); // 1
require_noerr(err, CantInstallAppleEventHandler);
CantInstallAppleEventHandler:
LOG_HIGH("@@@@@@@@ Registered Apple Event with " << err <<" code @@@@@@@");
return err;
} 我已经使用通配符标识符来获取所有事件。
在运行我的应用程序之后,我得到了成功注册的日志。
然后,我运行这个AppleScript来发送一个事件:
tell application "System Events" to get name of every process
tell application "System Events"
tell process "MyApp"
run
end tell
end tell 但我的应用程序中没有这个事件。我遗漏了什么?谢谢!
发布于 2015-05-13 19:36:30
您将要编写的脚本将向应用程序系统事件发送一个AppleEvent,这就是您的目标应用程序。因此,您需要做的是将您的脚本更改为如下所示:
tell application "MyApp" to launch此外,您应该回复事件ascr/noop,而不是****/**** (类型通配符/类型通配符)。
https://stackoverflow.com/questions/30208333
复制相似问题