문제

다음 사과 스크립트 코드는 잘 작동합니다.

tell application "Adium" to tell first account to make new chat with contacts {first contact} with new chat window

그러나 Cocoa의 스크립팅 브리지를 사용하여 어떻게 똑같이 할 수 있습니까?

도움이 되었습니까?

해결책

일반적으로, 당신은 Apple의 다음을 따라갈 수 있어야합니다. 코코아를위한 스크립팅 브리지 프로그래밍 안내서. 우선, 실행하여 Adium 용 헤더 파일을 만들었습니다. sdef /Applications/Adium.app | sdp -fh --basename Adium 터미널에서 (현재 디렉토리에서 adium.h를 생성). 제작 된 헤더 파일은 스크립팅 브리지를 통해 사과 스크립트 호출을 만드는 것에 대한 단서를 제공합니다.

내가 실행 한 문제는 생성 된 헤더 파일을 기반으로 할 방법을 볼 수 없다는 것입니다. make new chat with contacts {...} with new chat window (새 채팅을 할 수도 있고 새 창에 연결할 수도 있지만 그 채팅이 연락 할 수있는 방법을 찾을 수 없었습니다).

다음으로 가장 좋은 것은 사용하는 것입니다 nsapplescript 유효한 사과 코드를 실행하려면 :

NSAppleScript *appleScript = [[NSAppleScript alloc] initWithSource:@"tell application \"Adium\" to tell first account to make new chat with contacts {first contact} with new chat window"];
NSDictionary *errorDictionary;
NSAppleEventDescriptor *eventDescriptor = [appleScript executeAndReturnError:&errorDictionary];

다른 팁

Raw Apple 이벤트 코드를 사용하지 않으면 할 수 없습니다. 함께 일해야합니다 objc-appscript 그렇지만. AppScript의 AstranSlate 도구를 통해 AppleScrip 명령을 실행하면 다음이 생성됩니다.

#import "ADGlue/ADGlue.h"
ADApplication *adium = [ADApplication applicationWithName: @"Adium"];
ADReference *ref = [[adium accounts] at: 1];
ADMakeCommand *cmd = [[[[ref make] newChatWindow: ASTrue] withContacts: [NSArray arrayWithObject: [[[[adium accounts] at: 1] contacts] at: 1]]] new_: [ADConstant chat]];
id result = [cmd send];
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top