开发者

How to get variable value of applescript in cocoa?

开发者 https://www.devze.com 2022-12-16 03:55 出处:网络
NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init] ; NSAppleEventDescriptor *eventDescriptor;
    NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init] ;

 NSAppleEventDescriptor *eventDescriptor;
 NSAppleScript *script ;
 NSString* source ;
 NSDictionary* errorDic ;

 source=@"tell application \"iTunes\" \n"
 @"set tn开发者_如何学JAVAame to name of track 1 of playlist 1 \n"
 @"set tartist to artist of track 1 of playlist 1 \n"
 @"set talbum to album of track 1 of playlist 1 \n"
 @"set ttime to time of track 1 of playlist 1 \n"
 @"set tbitrate to bit rate of track 1 of playlist 1 \n"
 @"set tsize to size of track 1 of playlist 1 \n"
 @"set trating to rating of track 1 of playlist 1 \n"
 @"end tell";

 script = [[NSAppleScript alloc] initWithSource:source];
 eventDescriptor = [script executeAndReturnError:&errorDic];
 NSString* frontUrl = [eventDescriptor stringValue];
 NSLog(frontUrl);

 /*NSAlert *alert = [[NSAlert alloc]init];
 [alert setMessageText:frontUrl];
 [alert runModal];
 [alert release];*/

 [pool release] ;

NSlog only display a track rating. How to get value of tname,tartist,talbum,etc ?'

Thanks in advance


Applescript returns the value of the last statement executed. In this case, that's trating. Put a statement at the end that contains all the values (say, a list).

0

精彩评论

暂无评论...
验证码 换一张
取 消