Re: is Shane's advice being collated?
Re: is Shane's advice being collated?
- Subject: Re: is Shane's advice being collated?
- From: 2551 <email@hidden>
- Date: Thu, 20 Nov 2014 12:22:20 +0700
> On 20 Nov 2014, at 06:15, Shane Stanley <email@hidden> wrote:
>
>
> I'm going to assume from that you're talking theoretically, and you haven't done it much, if at all.
Your assumptions are wrong on both counts.
I've had my fair share of fun with NSAppleEventDescriptors, but people don't need to get involved with those or ASObjC just to mix a bit of AppleScript into an otherwise Cocoa-based app. Just running an NSTask and calling osascript would give more or less the same return as an AppleScript editor, hassle-free (for the interested, appended is a method I keep in Xcode's snippet editor for just this purpose).
You lament the lack of interest in ASObjC among scripters, and I'm pointing out why someone like myself - someone who sometimes needs more power than vanilla AS can provide - doesn't have an interest in it.
--------CODE SNIPPET---------
-(id)callOSATask: (NSString *)OSACmd {
NSString *reply;
NSTask *osaTask = [[NSTask alloc]init];
[osaTask setLaunchPath:@"/usr/bin/osascript"];
NSArray *osaArgs = [NSArray arrayWithObjects:@"-e", OSACmd, nil];
[osaTask setArguments:osaArgs];
NSPipe *replyPipe = [NSPipe pipe];
[osaTask setStandardOutput:replyPipe];
[osaTask launch];
NSData *replyData = [[replyPipe fileHandleForReading] readDataToEndOfFile];
reply = [[NSString alloc] initWithData:replyData encoding:NSUTF8StringEncoding];
return reply;
}
A trivial example of use:
NSString *theClipBoard = [self callOSATask: @"(the clipboard)"];
Best
Phil
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden