| |||
| [Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] |
| AppleScript wants newlines. If you were able to get error reporting, you'd find that it was complaining like this: 25:26: syntax error: Expected end of line but found unknown token. (-2741) Try: var commandLine = "/usr/bin/osascript -e 'tell application \"Mail\"\nactivate\nend tell\n'"; widget.system(commandLine, null); The system call just hands whatever your command is over to /bin/sh for interpretation, though by that time your _javascript_ will have already done some: \" to " and \n to a real newline and so forth. So you can always test on the command line. Also, system will for a process for every call, so I'd generally prefer to do this in objC anyway: - (void)activateMail; { NSString *scriptSource = @"tell application \"Mail\"\n" " activate\n" @"end tell\n"; NSAppleScript *script = [[NSAppleScript alloc] initWithSource:scriptSource]; NSDictionary *error = nil; [script executeAndReturnError:&error]; [script release]; if (error) { NSLog(@"error = %@", error); } } It gives you error reporting. If your script is expected to return results, you can get them from the return of executeAndReturnError: -Tom On May 19, 2005, at 5:50 AM, John Goodman wrote:
|
_______________________________________________ Do not post admin requests to the list. They will be ignored. Dashboard-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/dashboard-dev/email@hidden This email sent to email@hidden
| References: | |
| >AppleScript with widget.system (From: John Goodman <email@hidden>) |
| Home | Archives | FAQ | Terms/Conditions | Contact | RSS | Lists | About |
Visit the Apple Store online or at retail locations.
1-800-MY-APPLE
Contact Apple | Terms of Use | Privacy Policy
Copyright © 2007 Apple Inc. All rights reserved.