当前位置: 首页 > 工具软件 > ObjectScript > 使用案例 >

object-c执行applescript

乜思淼
2023-12-01

    NSString *string = [[[NSBundlemainBundle]resourcePath]stringByAppendingPathComponent:@"ping.scpt"];

   NSLog(@"%@",string);

   NSDictionary *errorInfo;

   NSAppleScript *appleScript = [[NSAppleScriptalloc]initWithContentsOfURL:[NSURLfileURLWithPath:string]error:&errorInfo];

    perror("script");

   NSLog(@"%@",errorInfo);

    

   Boolean isComple = [appleScriptcompileAndReturnError:&errorInfo];

   NSLog(@"%d %@",isComple,errorInfo);

   NSAppleEventDescriptor * descriptor = [appleScriptexecuteAndReturnError:nil];

   NSLog(@"%@",[descriptorstringValue]);


//script

do shell script "ping www.baidu.com" with administrator privileges



“双语播放器”已在app store上架,欢迎大家前去下载(主要用于看电影,学英语,程序员一定要学好英语!)

这里是链接:

https://itunes.apple.com/cn/app/shuang-yu-bo-fang-qi-kan-dian/id950279764?mt=8


 类似资料: