如何在可可中获取applescript的变量值?
NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init] ;
NSAppleEventDescriptor *eventDescriptor;
NSAppleScript *script ;
NSString* source ;
NSDictionary* errorDic ;
source=@"tell application \"iTunes\" \n"
@"set tname 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 仅显示曲目评级。如何获取 tname、tartist、talbum 等的值?
提前致谢
NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init] ;
NSAppleEventDescriptor *eventDescriptor;
NSAppleScript *script ;
NSString* source ;
NSDictionary* errorDic ;
source=@"tell application \"iTunes\" \n"
@"set tname 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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Applescript 返回最后执行的语句的值。在本例中,这就是
评级
。在末尾放置一条包含所有值的语句(例如,一个列表)。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).