Fetching result from NSAppleScript
Fetching result from NSAppleScript
- Subject: Fetching result from NSAppleScript
- From: Nirnimesh <email@hidden>
- Date: Thu, 19 Jul 2007 11:24:05 -0700
I'm quite a n00b to Cocoa.
I want to run an applescript and fetch its results in my cocoa app.
The applescript is: tell application \"Finder\" to get every window
#import <Cocoa/Cocoa.h>
int main(int argc, char *argv[]) {
NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
NSString* string = @"tell application \"Finder\" to get every window";
NSLog(string);
NSAppleScript* script = [[NSAppleScript alloc] initWithSource:string];
NSDictionary* errorDict = [NSDictionary alloc];
NSAppleEventDescriptor* des = [script executeAndReturnError:&errorDict];
NSData* rawdata = [des data];
NSString* out = [NSString stringWithCharacters:[rawdata bytes] length:
[rawdata length]/sizeof(unichar)];
printf("output %s", out);
[pool release];
return 0; //NSApplicationMain(argc, (const char **) argv);
}
The above doesn't work. I get:
output `\262\200\240\220
How can I fetch the output?
Thanks
--
Gravitation is not responsible for people falling in love.
-- Albert Einstein.
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden