• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Fetching result from NSAppleScript
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Prev by Date: Re: [ANN]CocoaTraces.com
  • Next by Date: Finder Open file versus double-clicking file
  • Previous by thread: Re: Character set mysteriously becomes null
  • Next by thread: Re: Fetching result from NSAppleScript
  • Index(es):
    • Date
    • Thread