dispatchRawAppleEvent:withRawReply:handlerRefCon:
アップルイベントを送信します
-(OSErr)dispatchRawAppleEvent:(const AppleEvent *)theAppleEvent: withRawReply:(AppleEvent *)theReply: handlerRefCon:(UInt32)handlerRefcon:
解説
アップルイベントを送信します。
他のアプリケーションにイベントを送るために使用することはできません。
アップルイベントを他のアプリケーションに送信するためにはCarbonフレークワークを利用する必要があります(10.2-10.3)
返り値
( OSErr )
エラーコード
引数
( const AppleEvent * )theAppleEvent
アップルイベント
( AppleEvent * )theReply
リプライ
( UInt32 )handlerRefcon
ハンドラ参照
フレームワーク
Foundation
クラス
NSAppleEventManager
Instance Methods
使用可能
10.0
参照
例文
#import "Controller.h" @implementation Controller -(void)awakeFromNib { aeMgr = [NSAppleEventManager sharedAppleEventManager]; [ aeMgr setEventHandler:self andSelector:@selector(handleAppleEvent:withReplyEvent:) forEventClass:kASAppleScriptSuite andEventID:kASCommentEvent ]; NSLog([[aeMgr currentAppleEvent] description]); } - (IBAction)pushButton:(id)sender { AppleEvent event, reply; OSErr err; OSType adrFinder = 'XXXX';// FSRef fileRef; AliasHandle fileAlias = NULL; err = FSPathMakeRef([@"/" fileSystemRepresentation], &fileRef,NULL); if (err != noErr) return; err = FSNewAliasMinimal(&fileRef, &fileAlias); if (err != noErr) return; err = AEBuildAppleEvent(kASAppleScriptSuite, kASCommentEvent, typeApplSignature,&adrFinder, sizeof(adrFinder), kAutoGenerateReturnID, kAnyTransactionID, &event, NULL,"'----':alis(@@)", fileAlias); if (err != noErr) return; aeMgr = [NSAppleEventManager sharedAppleEventManager]; [aeMgr dispatchRawAppleEvent:&event withRawReply:&reply handlerRefCon:nil ]; } - (void)handleAppleEvent:(NSAppleEventDescriptor *)inEvent withReplyEvent: (NSAppleEventDescriptor *)outReplyEvent { NSLog(@"!!!"); } @end