나는 당신이 애플 스크립트를 실행한다고 가정합니다. 당신이 실행할 많은 코드를 가지고 있다면 스크립팅 브릿지가 좋다. 그러나 당신은 단지 작은 금액을 누른 다음 간단한 방법은 NSApplescript입니다.
tell application "System Events"
set theProcesses to processes
repeat with aProcess in theProcesses
tell aProcess to get properties
end repeat
end tell
그런 다음 당신이이 방법을 쓸 수있는이 애플 스크립트를 실행하기를 원한다면 예를 들어
...
NSString* cmd = @"tell application \"System Events\"\nset theProcesses to processes\nrepeat with aProcess in theProcesses\ntell aProcess to get properties\nend repeat\nend tell";
NSAppleScript* theScript = [[NSAppleScript alloc] initWithSource:cmd];
NSDictionary* errorDict = nil;
NSAppleEventDescriptor* result = [theScript executeAndReturnError:&errorDict];
[theScript release];
if (errorDict) {
NSLog(@"Error:%@ %@", [errorDict valueForKey:@"NSAppleScriptErrorNumber"], [errorDict valueForKey:@"NSAppleScriptErrorMessage"]);
return;
}
// do something with result
NSLog(@"result: %@", result);
응용 프로그램의 "창 제목"? 응용 프로그램은 창문이 아닙니다. apps *에는 * windows, 각 응용 프로그램에 대한 하나 이상의 창이 있으며 각 창에는 제목이 있습니다. –